Open leebenson opened 1 year ago
This is expected behaviour, when using streaming your page will render after the headers and status have already been sent, which means that status will be 200 and redirect will be done using http-equiv meta tag https://developers.google.com/search/docs/crawling-indexing/301-redirects#metarefresh
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue
https://github.com/leebenson/nextjs-ssr-redirect-issue
To Reproduce
Run
npm run dev
andcurl -I localhost:3000/redirect
Describe the Bug
Motivated by https://github.com/vercel/next.js/discussions/45746
redirect
correctly returns a 307 when used in Server Components in theapp
folder with the Node.JS runtime, but returns200
when set toexperimental-edge
.Example...
next.config.js
src/app/redirect/page.tsx
Then start the server with
npm run dev
andcurl -I localhost:3000/redirect
.Notice the
200
response:If
runtime: "experimental-edge"
is removed from next.config.js, re-executingcurl -I localhost:3000/redirect
produces:⚠️: The HTML response is present in both runtimes. I would expect the server to respond with an 'empty' 307.
Expected Behavior
I'd expect a 307 response to be consistent in all runtimes.
I would also expect the response body to be empty and not contain the HTML bootstrapping.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
npm run dev