DEV Community 👩‍💻👨‍💻

Cover image for Overcome CORS errors during development in Chrome
Hardique Dasore
Hardique Dasore

Posted on • Updated on

Overcome CORS errors during development in Chrome

What is a CORS error?

Cross-Origin Resource Sharing (CORS) allows the website of one URL request data from a different URL.
CORS error is a mechanism to restrict users from accessing shared resources.

The browser blocks this to fight one of the most common cyber attacks i.e. cross-site request forgery.
The browser, therefore, throws an error every time, the website tries to fetch data from a different base URL.

To overcome CORS errors in Google Chrome, we need to disable the web security of the browser.

Please follow the below-mentioned steps:

  1. Open Start window
  2. Search Run and open it or press Window+ R
  3. Paste chrome.exe --user-data-dir="C://Chrome dev session" --disable-web-security and execute it

This will open a new browser with web security disabled.
You can now access your project in this browser without worrying about the CORS errors.

Note: This is a temporary fix and should only be used during the development phase.

Happy Coding!

Image description

Top comments (0)

🌚 Life is too short to browse without dark mode