简体   繁体   中英

I've deployed a nodejs api to Heroku and a React app to my personal site and I'm getting cors errors but going to the api url directly gets response?

I've written a NodeJs app with an express server that runs fine on heroku. From my local machine, with the proxy set in package.json of my React app, I can interact with the API. From the browser I can also interact with it. However the deployed React app on my site can't get the resources. Heroku is picking up the GET requests by the way.

I'm not very well versed in Dev ops, networking, deployment so I'm wondering where in the system I'm running into the problem and where I should look to fix the problem.

Edit : I've added the cors npm package. I can make fetch requests from the browser. But my site can't...

Def sounds like a cross origin error. The browser is masking error details from react for security purposes. Try adding npm install cors & then add it as middleware - you can view the npm package here

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