We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fc55342 commit 8c1e20dCopy full SHA for 8c1e20d
packages/react-scripts/scripts/start.js
@@ -203,6 +203,14 @@ function addMiddleware(devServer) {
203
var hpm = httpProxyMiddleware(pathname => mayProxy.test(pathname), {
204
target: proxy,
205
logLevel: 'silent',
206
+ onProxyReq: function(proxyReq, req, res) {
207
+ // Browers may send Origin headers even with same-origin
208
+ // requests. To prevent CORS issues, we have to change
209
+ // the Origin to match the target URL.
210
+ if (proxyReq.getHeader('origin')) {
211
+ proxyReq.setHeader('origin', proxy);
212
+ }
213
+ },
214
onError: onProxyError(proxy),
215
secure: false,
216
changeOrigin: true,
0 commit comments