Next.js Discord

Discord Forum

NextResponse.rewrite() with POST requests

Unanswered
Tomistoma posted this in #help-forum
Open in Discord
TomistomaOP
Does NextResponse.rewrite() pass the body of a post request to the target function?

8 Replies

@Tomistoma Does NextResponse.rewrite() pass the body of a post request to the target function?
I’m not sure but it should be yes :thinkies: have you tried?
TomistomaOP
I have, and it works, but there's a concern about what happens to the body.

It isn't documented and the behavior could be different once deployed (as I understand edge middleware works much differently).

So I'm looking for confirmation or maybe reassurance that it's used somewhere in production.
Using nextjs rewrite is a known way to do reverse proxy in production, it should work fine normally
TomistomaOP
I can't test this for another reason (haven't brought in NextResponse.rewrite yet), the requset gets stuck.
New to Next so I could be missing something obvious
TomistomaOP
thank you! that got the route to work
odd that it didn't respond with 404