Skip to content

Commit

Permalink
fix: Http proxy CORS problem, Keep origin by default. (#10699)
Browse files Browse the repository at this point in the history
Co-authored-by: xiezhiyong <[email protected]>
  • Loading branch information
dayongxie and xiezhiyong authored Aug 31, 2023
1 parent 5131a5f commit 8562ba3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/bundler-utils/src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export function createProxy(
...proxy,
onProxyReq(proxyReq, req: any, res) {
// add origin in request header
if (proxyReq.getHeader('origin')) {
proxyReq.setHeader('origin', new URL(proxy.target!)?.href || '');
if (proxy.changeOrigin && proxyReq.getHeader('origin')) {
proxyReq.setHeader('origin', new URL(proxy.target!)?.origin || '');
}
proxy.onProxyReq?.(proxyReq, req, res, proxy);
},
Expand Down

0 comments on commit 8562ba3

Please sign in to comment.