create-react-app proxy request fails with 404 when backend is hosted on Azure
create-react-app
use WebPackDevServer
which uses https://github.com/chimurai/http-proxy-middleware#options
So you can use all the options from the same
Now one key header
that is import in such cases of externally hosted server is host
. This at times can issues if not correct, see below example
Websocket works on EC2 url but not on ElasticBeanstalk URL
Next is the cookies might be associated with localhost
, i checked and they should go without any modification. But you might want to use the cookieDomainRewrite: ""
option as well
So the final config I would use is below
"proxy":{
"/api/*":{
"target":"https://mytestbackend.azurewebsites.net",
"secure":false,
"headers": {
"host": "mytestbackend.azurewebsites.net"
},
"cookieDomainRewrite": ""
}
}
Also on your client you want to use the withCredentials:true
let userinfo =await axios.get('/api/secured/userinfo',{withCredentials:true});