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: retain original request in middleware handler #1919

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

IdanLupinskyMyPorsche
Copy link

we noticed that custom headers from the original request were not retained as NextResponse.next was called without the original request

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • [n/a] I have added documentation for all new/changed functionality (or N/A)

📋 Changes

This should be a fix to allow the original request to be retained when passed through the middleware. We require this to retain a custom header in the original request.

📎 References

🎯 Testing

As you can see we updated one of the tests handling a "no matching auth route" to see that the NextResponse.next was called with the original NextRequest. In particular, we tested that the request passed is the same using a spy.

@IdanLupinskyMyPorsche IdanLupinskyMyPorsche requested a review from a team as a code owner February 14, 2025 15:47
@codecov-commenter
Copy link

codecov-commenter commented Feb 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.06%. Comparing base (fd6a68f) to head (770de96).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1919   +/-   ##
=======================================
  Coverage   76.06%   76.06%           
=======================================
  Files          20       20           
  Lines        1496     1496           
  Branches      233      233           
=======================================
  Hits         1138     1138           
  Misses        351      351           
  Partials        7        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

we noticed that custom headers from the original request were not retained as `NextResponse.next` was called without the original request
@tusharpandey13
Copy link
Contributor

lgtm

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