How to overcome the CORS issue in ReactJS

后端 未结 7 1861
失恋的感觉
失恋的感觉 2020-11-28 06:30

I am trying to make an API call through Axios in my React Application.However, Iam getting this CORS issue on my browser. I am wondering if i can resolve this issue from a c

7条回答
  •  难免孤独
    2020-11-28 06:46

    You can have your React development server proxy your requests to that server. Simply send your requests to your local server like this: url: "/" And add the following line to your package.json file

    "proxy": "https://awww.api.com"
    

    Though if you are sending CORS requests to multiple sources, you'll have to manually configure the proxy yourself This link will help you set that up Create React App Proxying API requests

提交回复
热议问题