1

I keep getting this error, I have used node & express at the back end and react at the front end

'Proxy error: Could not proxy request /api/profile from localhost:3000 to http://localhost:4321/. [1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).'

3 Answers 3

1

In my node server, I added res.header('Access-Control-Allow-Origin', '*'); in my app.use function. My function finally looks like this:

app.use((req, res, next) => {
  res.header('Access-Control-Allow-Origin', '*');
  next();
});

I didn't mess around with the package.json file.

Sign up to request clarification or add additional context in comments.

Comments

0

Did you add a proxy inside the react package.json? This error usually happens when you dont add the proxy.

1 Comment

Welcome to SO, please also show how he should do it by providing some example in your answer.
0

your proxy's port should be the same as that of your backend server's listening port.

for e.g in your case set the listening port of you backend sever to 4321.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.