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(redirect): Ignore query config after redirection #1724

Merged
merged 1 commit into from Oct 23, 2022

Conversation

IlyasShabi
Copy link
Contributor

@IlyasShabi IlyasShabi commented Oct 23, 2022

Ignore query option on redirection, please check #1691 for more information.
The issue can be reproduced with a simple node/express server:

app.get('/', (req, res) => { res.send('Hello world');});

app.get('/endpoint', (req, res) => { res.redirect('/redirection?param1=first');});

app.get('/redirection', (req, res) => { res.redirect('/');});

app.listen(4000, () => {})

Then we can call it with undici:

undici.request(
'http://localhost:4000/endpoint',
{
   maxRedirection: 4,
   query: { param: 'test' }
}
).then(res => console.log('Good')).catch(err => console.log(err));

The code snippet will produce an error as described in the issue.

Solution: Remove query from options after redirection

@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2022

Codecov Report

Base: 89.55% // Head: 89.56% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (3425f29) compared to base (54437e2).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1724   +/-   ##
=======================================
  Coverage   89.55%   89.56%           
=======================================
  Files          58       58           
  Lines        5258     5259    +1     
=======================================
+ Hits         4709     4710    +1     
  Misses        549      549           
Impacted Files Coverage Δ
lib/handler/RedirectHandler.js 95.00% <100.00%> (+0.06%) ⬆️

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.

@IlyasShabi IlyasShabi marked this pull request as ready for review October 23, 2022 00:10
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Lgtm

@mcollina mcollina merged commit f57fe82 into nodejs:main Oct 23, 2022
metcoder95 pushed a commit to metcoder95/undici that referenced this pull request Dec 26, 2022
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
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.

None yet

4 participants