Cross-Origin Request Blocked


#1

HI,

I am trying to access an API that is hosted on my C9 IDE instance. I am running a mobile webpage on another domain that calls the API. if I access the api url directly it works. but when the JS on the mobiel page calls it I get this error

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://hackathon-jachno.c9users.io/customer/checkcustomer/?. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

I have check the forums and the only suggestion has been to ensure that the url is shared as public. I have tried this but it is still not working

Thanks

Jachno


Hosting fonts in C9, cross-origin, access-control-allow-origin
#2

you need to set correct CORS headers to allow that see https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

in node.js you could do something like

res.writeHead(200, {
    "Access-Control-Allow-Origin": "*",
    "Access-Control-Allow-Methods": "PUT, GET, OPTIONS, HEAD"
});