-
Notifications
You must be signed in to change notification settings - Fork 28k
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
NextResponse.rewrite is not forwarding the request body to external hosts in dev when headers are modified in middleware #50200
Comments
+1 |
+1 this is preventing me from being able to adopt later versions. |
seems to be working for me in v13.4.7 |
+1. I upgraded from next v13.4.4 -> v13.4.7 and I'm still experiencing this issue. When I log the |
I updated the failing test branch to latest canary: #49606 Still failing the test:
Error:
|
@florianliebig I think this is not a bug. Can you confirm that you are passing Content-Type header? For me, the issue is reproducible if you don't explicitly pass that header. But if I do, it works just fine. I am using the edge function in the middleware |
Oh, thanks, man! This help was a lifesaver. I spent a week on it. |
Doesn't help for me. Issue is actually that the body stream is invalid which I was able to check with ngrok. Maybe thats not an issue for some backends if you don't have anything in body |
after setting the "Content-Type" , "application/json" in request, middleware rewrite and next.config rewrite worked correctly for me. |
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you. |
This issue has been automatically closed due to two years of inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding! |
Verify canary release
Provide environment information
Reproducable in canary with a jest test. Occurs beginning from Next 13.3 and all versions after that. ONLY AN ISSUE IN DEV MODE
Which area(s) of Next.js are affected? (leave empty if unsure)
Middleware / Edge (API routes, runtime)
Link to the code that reproduces this issue or a replay of the bug
#49606
To Reproduce
Create a middleware endpoint and Rewrite the response to an external API. Copy and modify the headers accordingly to https://vercel.com/templates/next.js/edge-functions-modify-request-header
Make an API call with a body (in this case json-data) in dev mode:
const res = await next.fetch( '/middleware-external-rewrite-body-headers', { redirect: 'manual', method: 'POST', body, } )
Check the body you receive in the external target
Describe the Bug
#48040 fixed the body rewrite to external resources. But as soon as you modify the headers in your middleware, still no body is received at the target:
` expect(received).toEqual(expected) // deep equality
#49606
I was also able to locally reproduce using ngrok.
Expected Behavior
The request body should always be rewritten fully in every case.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
next dev
The text was updated successfully, but these errors were encountered: