A
A
angelzzz2019-07-08 19:49:55
Node.js
angelzzz, 2019-07-08 19:49:55

How to solve proxy error in React when working with Node?

From time to time, when saving a project, this error occurs (this example actually happens with different references):

Proxy error: Could not proxy request /api/games/handle/:handle from localhost:3000 to http://127.0.0.1:5000.

My project structure is like this:
- client
-- package.json
- server
- package.json

Google suggested a solution to add the following sub to client/package.json:
"proxy": {
    "/api": {
      "target": "https://127.0.0.1:5000",
      "secure": false
    }
  },

But it does not help, the problem still occurs from time to time

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WizardW, 2019-07-11
@WizardW

I have this: Express:

app.use(
  cors({
    credentials: true,
    origin: ["http://localhost:3000"],
    optionsSuccessStatus: 200
  })
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question