_ff9dg
Last Updated: February 25, 2016
·
8.945K
· fdamilola
Img 2017 02 20 18 28 38

Enabling Cross Origin Resource Sharing (CORS) on Google Chrome for JavaScript API calls and Debugging purposes .

I recently started hacking around jQuery and AngularJS. I am a bit late to the party, I admit.

After a few hours of beginning, I had to make Ajax api requests to a domain not residing on my localhost.

That was when I came across a Cross Origin Resource Sharing (CORS) specific problem. Apparently, most browsers stop JavaScript from accessing resources that don't reside on the same server as the js file itself.

After a bit of research, I came across a little hack for Google Chrome that enables CORS.

Just start your chrome with this command :

$google-chrome --disable-web-security

This enables CORS on chrome for that session and enables you make your api calls.

Still hacking around JavaScript and I must say, I am loving it.

** EDIT 1 : **

As @pmcjury pointed out, you could just :

Enable CORS on your server serving the api.

Access-Control-Allow-Origin: * 

Visit : http://enable-cors.org/*

Say Thanks
Respond

3 Responses
Add your response

20760
None

thanks!

over 1 year ago ·
20773
898fe527971bf2b9f025347f44774bdd

You should enabled CORS on your server serving the api.

Access-Control-Allow-Origin: *

http://enable-cors.org/

over 1 year ago ·
21125
Img 2017 02 20 18 28 38

@pmcjury Yeah. But in this particular case, there was no access to the server.

over 1 year ago ·