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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With