How can I fix the "fetch" proxy error in create-react-app project?

2020-04-01 mysql node.js reactjs express proxy

I am writing an app that can use mySQL database to store user information (login, registration). The problem is that when I try to call a server from the frontend (via proxy in package.json), it returns me an 404 error. Frontend is based on a create-react-app template. I use Axios library on backend.

Screenshot is below.

enter image description here

(also you can see that some inputs are cleared automatically in Registration page when you try to type in something).

My package.json in create-react-app (I think there is something wrong exactly in package.json):

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "axios": "^0.19.2",
    "jwt-decode": "^2.2.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "proxy": "http://localhost:5000",
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Project on a Github: https://github.com/thesiv95/mysql-cra-01042020

Thanks for any help.

btw, author: https://www.youtube.com/watch?v=a1hhL9z-fbU

thanks a lot if you see my message!

Answers

I think that your server should run on port 5000 but you are making POST request to port 3000.

Related