Files
next.js/test/e2e/app-dir/middleware-rewrite-dynamic/middleware-rewrite-dynamic.test.ts
JJ KasperandGitHub 3e022577f2 Fix resolvedPathname for middleware rewrite (#81144)
This updates the handling of `resolvedPathname` to handle the case we
don't know the `rewroteURL` for example when it's a middleware rewrite
and we can't derive it since it's fully dynamic. Since we always know
the `srcPage` we can always recreate the final URL using the params
which this does as it's more reliable than relying on the parsed URL as
a backup.

Validated against our deploy tests
https://github.com/vercel/next.js/actions/runs/16014327609/job/45178072108
and
https://github.com/vercel/vercel/actions/runs/16014347060/job/45178081995?pr=13509

x-ref: [slack thread](https://vercel.slack.com/archives/C093RLQ7RGC)
2025-07-01 20:53:54 -07:00

20 lines
573 B
TypeScript

import { nextTestSetup } from 'e2e-utils'
describe('app dir - middleware rewrite dynamic', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should properly rewrite for /robots.txt', async () => {
const res = await next.fetch('/robots.txt')
expect(res.status).toBe(200)
expect(await res.text()).toContain('Render next')
})
it('should properly rewrite for /favicon.ico', async () => {
const res = await next.fetch('/favicon.ico')
expect(res.status).toBe(200)
expect(await res.text()).toContain('Render next')
})
})