Search code examples
google-chrome-extensionmanifest

Chrome extension to externally connect to any local IP


I am building an extension for chrome that should work with (externally connect to) one or more websites. To test it I have the website running on a server in the local network and connect to it from machines in the local network that have the extension installed.

I tried something like this

"externally_connectable": {
"matches": [
    "http://192.168.1.109:8080/*"
],
"accepts_tls_channel_id": false
},

in the manifest.json file but it didn't work. Ideally i would like to allow all urls to connect at least during development.


Solution

  • Unfortunately you cannot do that.

    Quoting the docs:

    The URL pattern must contain at least a second-level domain - that is, hostname patterns like "*", "*.com", "*.co.uk", and "*.appspot.com" are prohibited.

    While this does not specifically disallow IPs, apparently they don't work, and under no circumstance you can give a wildcard for any site:

    Patterns cannot include wildcard domains nor subdomains of (effective) top level domains; *://google.com/* and http://*.chromium.org/* are valid, while <all_urls>, http://*/*, *://*.com/*, and even http://*.appspot.com/* are not.

    For testing, you can assign a second-level domain to your local address in the hosts file for your OS.