Enabling Cross Origin Resource Sharing (CORS) on Chrome for API calls


So I have been working on a SPA project which uses API calls and I have had a headache with Cross Origin Resource Sharing (CORS)  setup on Chrome because APIs aren’t on my localhost naturally, making a call to other domain. hence the problem of CORS cause Chrome doesn’t let you access resources which aren’t on the same server as your app.

long story short, I found this hack which comes in handy with this problem. just follow below steps:

  1. go to “C:\Program Files (x86)\Google\Chrome\Application” address.
  2. right click on Chrome’s icon, right click and then send to desktop.
  3. go back to the desktop and right click on the shortcut you just created.
  4. select Target from Shortcut tab and enter “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe” –disable-web-security –user-data-dir=”c:/Chrome”
  5. press ok and start Chrome from the shortcut.
  6. you’ll get a notification saying “You are using an unsupported command-line flag…” just ignore that and run your app.

 

 

 

 

Ramin Ahmadi
I am a full-stack front end developer with over 5 years experience in web design and development. I have worked with a wide variety of environments and languages including Angular, TypeScript, NodeJS, Restful API, Microservices, Atomic design, JQuery, Material design, Progressive Web Apps, DevOps, and many Azure tools. I make it a goal to automate myself out of routine tasks in my daily work. My motto is, ‘write human readable code, lean and clean’.

Comments 0

Your email address will not be published. Required fields are marked *

Enabling Cross Origin Resource Sharing (CORS) on Chrome for API calls

log in

Captcha!

reset password

Back to
log in
Choose A Format
Trivia quiz
Series of questions with right and wrong answers that intends to check knowledge
Poll
Voting to make decisions or determine opinions
List
The Classic Internet Listicles
Image
Photo or GIF
Gif
GIF format