Could not proxy request /pusher/auth from localhost:3000 to http://localhost:5000 (ECONNREFUSED)

后端 未结 13 890
半阙折子戏
半阙折子戏 2020-12-09 09:48

I am trying to create a chat app using reactJS and pusher, i am getting this error-

Could not proxy request /pusher/auth from localhost:3000 to http

相关标签:
13条回答
  • 2020-12-09 09:58

    I faced a similar issue but in Mac machine. I changed localhost to 127.0.0.1 and that worked for me.

    For windows:

    "proxy": {
      "/auth/google": {
        "target": "localhost:5000"
      }
    }
    

    For Mac:

    "proxy": {
      "/auth/google": {
        "target": "http://127.0.0.1:5000"
      }
    }
    
    0 讨论(0)
  • 2020-12-09 10:02

    My issue was trying to run my react project with docker containers open.

    Change the ports or shut down the containers.

    0 讨论(0)
  • 2020-12-09 10:03

    In your server package.json add --ignore client to your "start" or "server" scripts. So it would look like this:

     "scripts": {
     "start": "node index.js",
     "server": "nodemon index.js --ignore client"
     }
    
    0 讨论(0)
  • 2020-12-09 10:03

    I think Server not working properly, you should run client and server concurrently for that add following procedures in package.json file

    1) Install concurrently

    npm install concurrently --save
    

    2) configure client and server

    "server": "nodemon server.js",
    "client": "npm start --prefix client"
    

    3) configure concurrently

    "dev": "concurrently "npm run server" "npm run client""
    
    0 讨论(0)
  • 2020-12-09 10:03

    Use "proxy":"http://localhost:PORT_NUMBER/" in package.json

    and in axios backend call route like use axios.get("api/user/getinfo") instead of axios.get("/api/user/getinfo");

    0 讨论(0)
  • 2020-12-09 10:06

    In server directory

    npm install --save http-proxy-middleware
    

    then create a file with this name : setupProxy.js in src directory of client react folder

    then add the following

    const proxy = require("http-proxy-middleware");
    module.exports = function(app) {
      app.use(proxy("/api/**", { // https://github.com/chimurai/http-proxy-middleware
        target: "http://localhost:5000",
        secure: false
      }));
    };
    

    In proxy configuration make sure you are matching any path with double ** not only *

    Note: you are not going to require this proxy anywhere else just like that

    Note: remove any other proxy settings in package.json For more check this reference

    0 讨论(0)
提交回复
热议问题