Description
When redirecting a data request, middleware returns a response with x-nextjs-redirect
, rather than a location
header. We handle this correctly. However Next.js expects us to directly return and empty response with a 302 response code (without the location header), whereas we're currently passing the request on to the origin and returning the body with 404 code. I'm unsure if it's legal to return a 302 with no location, but it's what next start does, and the router expects.
Data
The following is parsed automatically by the Next.js repo e2e test report generator.
test case: https://github.com/vercel/next.js/blob/canary/test/e2e/middleware-redirects/test/index.test.ts#L100
test: test/e2e/middleware-redirects/test/index.test.ts
reason: Pages router middleware should return 302 status for redirected data requests