If I'm serving a react application with npm install -g serve; serve -s build
, is it possible to also have a location proxy?
Ex: any requests to https://example.com/api/*
will be redirected to https://example.com:8000/api/*
If I'm serving a react application with npm install -g serve; serve -s build
, is it possible to also have a location proxy?
Ex: any requests to https://example.com/api/*
will be redirected to https://example.com:8000/api/*
You can try proxy in package.json
"proxy": {
"/api": {
"target": "http://localhost:3001"
},
"/assets": {
"target": "http://localhost:3001"
}
},
You may also check environment config options here if above does not solve: https://docs.npmjs.com/misc/config#proxy