Hayden Shaw
Hayden Shaw

Reputation: 75

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

Upvotes: 1

Views: 65

Answers (1)

zacharycwilliams
zacharycwilliams

Reputation: 26

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

Upvotes: 1

Related Questions