Access to XMLHttpRequest has been blocked by CORS policy

后端 未结 7 2251
庸人自扰
庸人自扰 2021-02-18 16:49

I\'ve a problem when I try to do PATCH request in an angular 7 web application. In my backend I have:

app.use((re         


        
7条回答
  •  悲哀的现实
    2021-02-18 17:12

    There are two ways this can be handled:

    1. 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.

    1. Permanent solution:

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

    Let me know if it works.

提交回复
热议问题