Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9d42ffa

Browse filesBrowse files
kolesgaearon
authored andcommitted
Proxy rewrites Origin header to match the target server URL (facebook#1212)
* Proxy rewrites Origin header to match the target server URL * Added comments on rewriting Origin header by the proxy middleware
1 parent 801b955 commit 9d42ffa
Copy full SHA for 9d42ffa

File tree

Expand file treeCollapse file tree

1 file changed

+8
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-0
lines changed

‎packages/react-scripts/scripts/start.js

Copy file name to clipboardExpand all lines: packages/react-scripts/scripts/start.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ function addMiddleware(devServer) {
201201
var hpm = httpProxyMiddleware(pathname => mayProxy.test(pathname), {
202202
target: proxy,
203203
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+
},
204212
onError: onProxyError(proxy),
205213
secure: false,
206214
changeOrigin: true,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.