Skip to content

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

Merged
pi0 merged 2 commits intoh3js:mainfrom
emilsgulbis:patch-1
Jul 17, 2023
Merged

fix(proxy): respect fetchOptions.method over incoming request method#441
pi0 merged 2 commits intoh3js:mainfrom
emilsgulbis:patch-1

Conversation

@emilsgulbis
Copy link
Copy Markdown
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
Copy Markdown
Contributor

@emilsgulbis

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

@codecov
Copy link
Copy Markdown

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
Comment thread src/utils/proxy.ts Outdated
Copy link
Copy Markdown
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 h3js:main Jul 17, 2023
@pi0
Copy link
Copy Markdown
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