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
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"
}
}
My issue was trying to run my react project with docker containers open.
Change the ports or shut down the containers.
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"
}
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""
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");
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