Access to XMLHttpRequest at httpsmcboxmynavijpcorpsubmission-contentlistsourceSystemType=1&sourceCompanyCode=1160 from origin httplocalhost3000 has been blocked by CORS policy Response to preflight re
This error message is related to the Cross-Origin Resource Sharing (CORS) policy. It indicates that the browser is blocking the XMLHttpRequest (XHR) request from your localhost (http://localhost:3000) to the specified URL (https://mcbox.mynavi.jp/corp/submission-content/list/?sourceSystemType=1&sourceCompanyCode=1160) because the server does not include the necessary 'Access-Control-Allow-Origin' header in the response.
CORS is a security mechanism implemented by browsers to prevent requests from different origins (domains) unless the server explicitly allows it. The server needs to include the 'Access-Control-Allow-Origin' header in the response, specifying the allowed origins.
To resolve this issue, you have a few options:
-
Modify the server-side code: If you have access to the server-side code, you can modify it to include the 'Access-Control-Allow-Origin' header in the response. For example, in a Node.js/Express server, you can use the
corspackage to enable CORS and set the allowed origins. -
Proxy the request: Instead of making the XHR request directly from your frontend code, you can set up a proxy server on your backend that forwards the request to the desired URL. This way, the request will be made from the same origin as your frontend, avoiding the CORS issue.
-
Use a browser extension: You can use browser extensions like Moesif CORS or CORS Unblock to temporarily bypass the CORS policy during development. However, these extensions should not be used in a production environment.
It's important to note that resolving the CORS issue depends on your specific situation and the control you have over the server-side code
原文地址: https://www.cveoy.top/t/topic/hWSH 著作权归作者所有。请勿转载和采集!