CORS Issue in Chrome Developer Extension

459 views
Skip to first unread message

atanu mallik

unread,
Nov 29, 2016, 2:42:33 AM11/29/16
to Google Chrome Developer Tools
I am a novice in Chrome Extension Development and I am developing a Chrome Developer Extension (appears as a part of Developer Tools). 
The requirement is to make External Service (some URL )call which may or may not be in the same Server (of origin). From the documentation I see the extensions are not restricted by the Same Origin Policy. 


However I am running into CORS issue while I try to call an external service.

The Manifest.json looks like the below one, where I have permission to all websites.

"permissions": [
        "tabs",
        "clipboardWrite",
        "http://*/*",
        "https://*/*"
    ],

In the code I am trying to call HTTP POST on some URL , the code looks like

gwUrl = 'http://services.odata.org/V2/(S(lts2i32bwwy01zoq4cxyscwt))/OData/OData.svc/Products';
var xhr = new XMLHttpRequest();
xhr.open("POST", gwUrl , true);
xhr.setRequestHeader("Content-type", "application/json");
xhr.onreadystatechange = function() {}
xhr.send({ "ID":17, "Name": "Bread", "Description": "Whole grain bread"});   


I am getting the following Error.


XMLHttpRequest cannot load http//services.odata.org/V2/(S(lts2i32bwwy01zoq4cxyscwt))/OData/OData.svc/Products. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'chrome-extension://cdcbiglainpfeapfejdjdkldcehjakfi' is therefore not allowed access. The response had HTTP status code 501.

Can anyone help me regarding this issue.

Regards
Atanu 

PhistucK

unread,
Nov 29, 2016, 2:44:09 AM11/29/16
to Google Chrome Developer Tools
​​

I guess you should use message passing and let your background page perform the request instead. :(


PhistucK

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/ab4a7530-e820-41e1-a894-947a5b8a4b3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages