Skip to content

Middleware data redirects should normalize destination #1800

Closed
@ascorbic

Description

@ascorbic

In middleware we intercept redirects inside data requests (i.e. those in /_next/data/..) and set the x-next-redirect header instead. This is because the router handles the redirect instead. However we're currently not normalizing the redirect target. The correct behaviour should be to always set it to the normalized path, even if the target is for the data URL. e.g. a redirect to /_next/data/build-id/en-gb/hello.json?foo=bar should be normalized to /en-gb/hello?foo=bar. Next.js implements this here

e2e test: middleware-redirects

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions