I'm developing an web application that needs to access a remote server through JSON from the browser, but the remote server does not support CORS. The server will eventually support CORS. But I need the browser to access the remote server during my development and testing phase.
How can I get the browser to allow responses from servers that do not have CORS enabled?
Newer browsers have security limitation for Cross-Origin resource sharing (CORS). For these browsers, if the response header from the servers do not contain “Access-Control-Allow-Origin: *” then the browser may raise an error such as:
Although this is an old question, I hope this answer will be helpful to anyone looking for a cheap, temporary patch to avoid CORS policy.
If you are using Google Chrome, there is a command line option wich you can disable CORS restriction with. Simply create a new plain text file and put this inside:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --disable-gpu --user-data-dir=~/chromeTemp
Just save this file as something.bat in Windows to ease its use. Or you can use the modifiers directly in terminal (works for both windows/unix environment).
Important sidenote: This is just a cheap, fast and dirty workaround JUST for developing environments. Please do not consider this possibility for production environments nor users. The best way to fix CORS is by really fixing CORS headers on server-side.