Web security can be pretty annoying especially when you are trying to perform simple API requests, CORS (Cross Origin Resource Sharing) can be an issue especially when the website you are making the API request from is not listed as part of the sites that can access the API.
What I meant is this
So, if it does happen that you want to access the above api but are not coming from this url: origin-domain.com, you can still access it by DISABLING WEB SECURITY in your browser (e.g chrome)
That’s pretty cool right? Please note that this method is not safe as it exposes whatever information you input into the browser to hackers, but for testing purposes, you are good to go.
So, lets begin: (For windows users)
Perform the following command “WINDOWS + R” and click on the “OK” button, or you can open your system’s command prompt using however method you choose
Once command prompt opens up, type in the following command:
”C:\Program Files (x86)\Google\Chrome\Application\chrome.exe” — disable-web-security — disable-gpu — user-data-dir=~/chromeTemp
This will open up an instance of your chrome web browser but with web security disabled in it. It should look like this
Voila! You are good to go in testing your code with that API that’s acting up cause of CORS policy.
Hope you enjoyed this article, if yes, hit that like button! Thanks do have a nice day.