简体   繁体   中英

ERROR : No 'Access-Control-Allow-Origin' header is present on the requested resource

I have been using axios in react. Since I made a cross domain request. I have been facing this issue. Although i have gone through all the solutions by adding headers.

await axios.get(`http://abc.in`,{headers: { 'Access-Control-Allow-Origin': '*', }}); .

Also added proxy in my package.json "proxy":"http://abc.in"

The Access-Control-Allow-Origin header is sent by the server as response header (whereas you are sending it in the request and this will have no effect) to tell the browser that the content of this page is accessible to certain origins (in this case the asterisk means all origins). If the server you are making a request to doesn't allow cross-origin requests, or it does but your domain is not in the list of accepted domains, you will not be able to access it.

An detailed explaination of how this works is here: How does Access-Control-Allow-Origin header work?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM