Last Updated: February 25, 2016
·
2.508K
· otobrglez

Fixing CORS errors (Access-Control-Allow-Origin)

There comes a time in developers life when he gets sh* load of:

XMLHttpRequest cannot load http://api.com. Origin http://api.com is not allowed by Access-Control-Allow-Origin.

Then you can do

./Applications/Google Chrome.app/Contents/MacOS/Google\ Chrome --disable-web-security

Or you can add header to your api.com responses with

Access-Control-Allow-Origin: *

And then in your time you can also read... http://www.w3.org/TR/cors/#access-control-allow-origin-response-header

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside