DEV Community

Chamara Silva
Chamara Silva

Posted on

How to solve Access to XMLHttpRequest has been blocked by CORS policy

Image description
There are two ways this can be handled:

Temporary Front-End solution so you can test if your API integration is working:
Click on window -> type run and hit enter -> in the command window copy:

chrome.exe --user-data-dir="C://Chrome dev session" --disable-web-security

This will open a new "Chrome" window where you can work easily. This is a temporary solution. Every time you will have to work with this chrome window.

Permanent solution:
In the backend code, the developer needs to add an annotation @Crossorigin right above the CRUD api call method.

Lot of developers wasting there time trying to fixing this issue.these are the two easy solutions.

Top comments (0)