Unverified Commit 8fb2f591 authored by Hannes Bornö's avatar Hannes Bornö Committed by GitHub

Add status code to app-render redirect response (#45846)

parent 7bbd239f
......@@ -2020,6 +2020,9 @@ export async function renderToHTMLOrFlight(
if (err.digest === NOT_FOUND_ERROR_CODE) {
res.statusCode = 404
}
if (err.digest?.startsWith(REDIRECT_ERROR_CODE)) {
res.statusCode = 307
}
const renderStream = await renderToInitialStream({
ReactDOMServer,
......
......@@ -181,6 +181,17 @@ createNextDescribe(
expect(await browser.url()).toBe(next.url + '/redirect-dest')
})
})
describe('status code', () => {
it('should respond with 307 status code in server component', async () => {
const res = await next.fetch('/redirect/servercomponent')
expect(res.status).toBe(307)
})
it('should respond with 307 status code in client component', async () => {
const res = await next.fetch('/redirect/clientcomponent')
expect(res.status).toBe(307)
})
})
})
describe('nested navigation', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment