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(proxy): respect fetchOptions.method over incoming request method #441

Merged
merged 2 commits into from
Jul 17, 2023
Merged

fix(proxy): respect fetchOptions.method over incoming request method #441

merged 2 commits into from
Jul 17, 2023

Conversation

emilsgulbis
Copy link
Contributor

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

When proxyRequest is used with different method (e.g. GET) defined in fetchOptions, the body is still filled and returns Request with GET/HEAD method cannot have body.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

If fetchOptions.method passed use it. 
Prevents "body" assign
@NozomuIkuta
Copy link
Member

@emilsgulbis

Would you add unit test?
https://github.com/unjs/h3/blob/main/test/proxy.test.ts

@codecov
Copy link

codecov bot commented Jul 15, 2023

Codecov Report

Merging #441 (50697f8) into main (d11f817) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #441   +/-   ##
=======================================
  Coverage   77.74%   77.74%           
=======================================
  Files          26       26           
  Lines        2692     2692           
  Branches      393      394    +1     
=======================================
  Hits         2093     2093           
  Misses        599      599           
Impacted Files Coverage Ξ”
src/utils/proxy.ts 81.51% <100.00%> (ΓΈ)

@pi0 pi0 changed the title fix(proxy): use passed fetchOptions "method" fix(proxy): respect fetchOptions.method over incoming request method Jul 17, 2023
src/utils/proxy.ts Outdated Show resolved Hide resolved
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pi0 pi0 merged commit a3192fb into unjs:main Jul 17, 2023
@pi0
Copy link
Member

pi0 commented Jul 17, 2023

Adding an additional test would be nice btw (however is not necessary)

@pi0 pi0 mentioned this pull request Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants