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