CORS hassle free proxy
See original GitHub issueIf I’m missing something and/or wrong about this, please correct me, thanks!
I find the implementation using https://github.com/chimurai/http-proxy-middleware is convenient, except that it’s not always so simple when facing Access-Control
header restrictions, which often requires the API/Data/Backend server to configure CORS.
One sure way I can think of is to use an HTTP client library such as https://github.com/mzabriskie/axios or https://github.com/request/request to make the request through server side (which to my understanding isn’t restricted by the cross-origin settings anymore) and pipe the retrieved response to the client, like req.pipe(request({...API_OPTIONS...})).pipe(res)
for the simplest example inside the API tunneling/proxy middleware.
Again, maybe I’m missing something very obvious and dead simple to achieve the same through http-proxy-middleware
, in which case please point out.
Issue Analytics
- State:
- Created 7 years ago
- Comments:19 (3 by maintainers)
Not sure if that’s related, but here’s my dev-server config:
Works with CORS and cookie authentication.
Since this issu eis quite old, and we will switch to webpack-dev-server in the coming days, I wil close this. If this still needs further discussion, please open a new issue with a reference to this one and we will see how to resolve this in the new envorinment with
webpack-dev-server
, if necessary.