create-react-app
docs says you can configure your proxy objects manually. I'm following the http-proxy-middleware
docs on matching
to exclude a specific route but haven't got it to work.
Basically I'm serving my app from the /app
route instead of root. So I want the following to happen:
/app/api
proxies to http://localhost:3001
, my backend service/app
proxy to http://cloud.my-app.com
This is what I've tried so far with no luck:
"homepage": "https://cloud.my-app.com/app",
"proxy": {
"/app/api": { // Works
"target": "http://localhost:3001"
},
"!/app/*": { // Does not work
"target": "https://cloud.my-app.com",
"secure": false
}
},
What am I missing?
Add the below as your proxy:
"proxy": {
"/app/api":{
"target":"http://localhost:3001",
},
"/.*/":{
"target":"https://cloud.my-app.com",
"secure":"false",
"changeOrigin": true
}
}