Janmesh Nayak
Janmesh Nayak

Reputation: 47

API in nodejs Port Issue

I've created an API in nodejs backend and frontend I used reactjs as I've connected the api to my form

it shows the error

"Could Not proxy request"

enter image description here

Upvotes: 0

Views: 133

Answers (2)

logeekal
logeekal

Reputation: 525

Check what is the error in Chrome developer tools. It is most probably CORS issue.

If you are using NodeJs, you can use below command.

res.header("Access-Control-Allow-Origin", "*");

But this will allow CORS for all port running on your machine.

I faced the same issue when using express. I resolved it as shown below : enter image description here enter image description here

Upvotes: 1

vishnu prasath
vishnu prasath

Reputation: 112

TRY THIS OUT IN YOUR PACKAGE.JSON CONFIGURATION refereed from create-react-app

"proxy": {
"/api": {
  "target": "https://localhost:5002",
  "secure": false
  }
},

Also try add CORS configuration to your node check this video

Upvotes: 0

Related Questions