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

后端 未结 13 930
半阙折子戏
半阙折子戏 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 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

提交回复
热议问题