How to disable same-origin policy in Chrome for testing AJAX requests?
Hi everyone! I'm new to web development and writing a small application in pure JavaScript. I need to make an AJAX request to a third-party API (e.g., a weather service) to get data and display it on the page. But when I run my code locally (just opening index.html in the browser), I get an error in the Chrome console:
Access to XMLHttpRequest at 'https://api.example.com/data' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I understand this is related to the same-origin policy (restricting access to resources from a different domain). I've read that you can run Chrome with this policy disabled for development, but I can't find a working method. I tried the --disable-web-security flag, but it doesn't help.
No answers yet.
Log in to leave an answer