1

Please note that all similar questions I could find on SO are ones trying to access localhost from a website, and I'm trying to access from an extension.

The difference? A website you just need to update to https, but I cannot update my extension to https. The origin is chrome-extension:// not even http://

The error is as follows:

Access to fetch at 'http://localhost:1784/myrestapi' from origin 'chrome-extension://asjdkhjhgaqnmpasorhwkq' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space local.

You see, that renders all suggestions to make the origin https invalid.

I've tried disabling the block-insecure-private-network-requests flag and enabling allow-insecure-localhost flag, but unfortunately they're of no use. It seems a ridiculous idea having to make the localhost https.

The host permission does include all urls for the extension, and this is only happening on some machines, and it runs perfectly on the other computers, all with the latest chrome. Any ideas?

halfer
  • 19,824
  • 17
  • 99
  • 186
Nicholas
  • 747
  • 7
  • 23
  • Does this answer your question? [Can't connect to localhost from Chrome extension](https://stackoverflow.com/questions/7668502/cant-connect-to-localhost-from-chrome-extension) – erik258 Mar 23 '23 at 19:10
  • No, and as I have already stated in my question, I do have the proper host permission. Thus the answer of the question you've linked is what I've already done. – Nicholas Mar 23 '23 at 19:12
  • you may not like the answer, but the question is still a duplicate. – erik258 Mar 23 '23 at 19:13
  • OK, consider this as a follow-up question then? Coz the answer in that question doesn't work, and I've clear stated so (that I do have host permission) in my question so that makes my question have a different precondition than the other one – Nicholas Mar 23 '23 at 21:07
  • 1
    Maybe you didn't reload the extension after editing? Try specifying [CSP in manifest.json](https://developer.chrome.com/docs/extensions/mv3/manifest/content_security_policy/). See if `chrome://policy` page has localhost in ExtensionSettings' runtime_blocked_hosts. – wOxxOm Mar 23 '23 at 21:49

0 Answers0