Search code examples
google-app-enginegoogle-chrome-extensionlocalhost

Can't connect to localhost from Chrome extension


I am working on a Chrome extension that tracks time, and uses Google App Engine for the backend.

For testing, I'm trying to connect a local version of the extension to a local version of the App Engine app. When I try to send a POST request, I'm getting:

XMLHttpRequest cannot load http://localhost:8080/report. Origin chrome-extension://mbndmimplohfkkcincjodnfpaapbbmei is not allowed by Access-Control-Allow-Origin.

But it works when I change the URL so that it posts to the appspot.com URL.

What is the Access-Control-Allow-Origin, and why is it stopping me from getting results from localhost?


Solution

  • I believe this is because you cannot make calls to a server that is not included in the permissions section of your manifest. The permissions section of manifest.json should look something like this:

    "permissions": [
      "http://myapp.appspot.com/*",
      "http://localhost/*"
    ]
    

    Note, I haven't tested this, but it sounds like that is where your problem is coming from.