Commit 9d42ffab authored by Pavel Kolesnikov's avatar Pavel Kolesnikov Committed by Dan Abramov
Browse files

Proxy rewrites Origin header to match the target server URL (#1212)

* Proxy rewrites Origin header to match the target server URL

* Added comments on rewriting Origin header by the proxy middleware
parent 801b9551
No related merge requests found
Showing with 8 additions and 0 deletions
+8 -0
......@@ -201,6 +201,14 @@ function addMiddleware(devServer) {
var hpm = httpProxyMiddleware(pathname => mayProxy.test(pathname), {
target: proxy,
logLevel: 'silent',
onProxyReq: function(proxyReq, req, res) {
// Browers may send Origin headers even with same-origin
// requests. To prevent CORS issues, we have to change
// the Origin to match the target URL.
if (proxyReq.getHeader('origin')) {
proxyReq.setHeader('origin', proxy);
}
},
onError: onProxyError(proxy),
secure: false,
changeOrigin: true,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment