Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Http proxy CORS problem, Keep origin by default. #10699

Merged
merged 1 commit into from
Aug 31, 2023

Conversation

dayongxie
Copy link
Contributor

#10692
我修改了一下这段代码,默认情况下不修改Header中的Origin字段,以避免CORS问题
在开启changeOrigin的情况下,http-proxy库会修改Header中的host字段,但是不会修改Origin字段,所以也会导致CORS问题
我加了个判定,changeOrigin开启的时候,修改Origin字段。 这样做既可以让changeOrgin这个控制参数更符合预期,同时避免了CORS问题

修改之后的changeOrigin行为:

  • changeOrigin为false:默认行为,不改变请求的origin和host
  • changeOrigin为true:请求的origin和host会替换为target的origin
    两种模式都不会有CORS问题

@vercel
Copy link

vercel bot commented Mar 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
umi ⬜️ Ignored (Inspect) Mar 7, 2023 at 4:59PM (UTC)

@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (55d6adf) 28.90% compared to head (3bcb75c) 28.90%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10699   +/-   ##
=======================================
  Coverage   28.90%   28.90%           
=======================================
  Files         458      458           
  Lines       13653    13653           
  Branches     3201     3201           
=======================================
  Hits         3946     3946           
- Misses       9024     9025    +1     
+ Partials      683      682    -1     
Impacted Files Coverage Δ
packages/bundler-utils/src/proxy.ts 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sorrycc sorrycc merged commit 8562ba3 into umijs:master Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants