I am trying to load data using an AJAX request in my Chrome Extension. It is my understanding that when using Chrome extensions you can make an AJAX request and don't have to worry about the same origin policy as long as you set the appropriate permissions.
However after setting the correct permissions (at least I think I did) I still get an error:
XMLHttpRequest cannot load https://stackoverflow.com/posts/popup/close/9498103. Origin chrome-extension://bcbifciedokdgkokbbfippkbecnkpclj is not allowed by Access-Control-Allow-Origin.
My permissions (as set in my manifest.json file) is part of this project may you also need to see other code:
"permissions": [
"http://stackoverflow.com",
"https://stackoverflow.com",
"http://*.stackoverflow.com",
"https://*.stackoverflow.com"
]
Is there something I missed or is it simply not possible?
Mentioning the host is not enough, you have to add /*
after each domain.
"permissions": [
"https://stackoverflow.com/*",
"https://stackoverflow.com/*",
"http://*.stackoverflow.com/*",
"https://*.stackoverflow.com/*"
]
A ready-to-use cross-domain XHR demo can be found at this answer: Cross-domain XMLHttpRequest using background pages