我正在构建一个 Chrome 扩展程序,它应该与一个或多个网站配合使用(外部连接到)。为了测试它,我让网站在本地网络中的服务器上运行,并从本地网络中安装了扩展程序的计算机连接到该网站。
我尝试过这样的事情
"externally_connectable": {
"matches": [
"http://192.168.1.109:8080/*"
],
"accepts_tls_channel_id": false
},
在 manifest.json
文件中,但它不起作用。理想情况下,我希望至少在开发期间允许所有网址连接。
最佳答案
不幸的是,你不能这样做。
引用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.
虽然这并没有明确禁止 IP,但显然它们不起作用,并且在任何情况下您都不能给出 a wildcard for any site :
Patterns cannot include wildcard domains nor subdomains of (effective) top level domains;
*://google.com/*
andhttp://*.chromium.org/*
are valid, while<all_urls>
,http://*/*
,*://*.com/*
, and evenhttp://*.appspot.com/*
are not.
为了进行测试,您可以将二级域名分配给 hosts
file 中的本地地址。适用于您的操作系统。
关于google-chrome-extension - Chrome 扩展程序可外部连接到任何本地 IP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27171543/