Files
9931cc0c85 Fix fallback route params case in app-page handler (#91737)
## Summary
- add production-route-shape fixture coverage for
`/[teamSlug]/[project]/settings/domains`
- add revalidation helpers (API and server action) and browser controls
used by the regression test
- reproduce the failing production sequence by priming, revalidating,
then loading a page with in-view `next/link` and navigating repeatedly

x-ref: https://github.com/vercel/next.js/pull/91627
x-ref: https://github.com/vercel/next.js/pull/91603

## Testing
- `IS_WEBPACK_TEST=1 NEXT_SKIP_ISOLATE=1 NEXT_TEST_MODE=start pnpm
testheadless
test/e2e/app-dir/segment-cache/vary-params-base-dynamic/vary-params-base-dynamic.test.ts
-t "production route shape"` (passes)
- `NEXT_ENABLE_ADAPTER=1 pnpm test-deploy
test/e2e/app-dir/segment-cache/vary-params-base-dynamic/vary-params-base-dynamic.test.ts
-t "production route shape"`
- `NEXT_ENABLE_ADAPTER=1 pnpm test-deploy
test/e2e/app-dir/segment-cache/vary-params-base-dynamic/vary-params-base-dynamic.test.ts`
(fails in the two production-shape cases)

---------

Co-authored-by: Zack Tanner <[email protected]>
2026-04-06 09:37:22 -07:00

60 lines
1.5 KiB
TypeScript

import { revalidatePath, revalidateTag } from 'next/cache'
import { NextRequest } from 'next/server'
type RevalidateMode =
| 'tag-layout-expireNow'
| 'tag-layout-max'
| 'tag-layout-legacy'
| 'path-root-layout'
| 'path-team-layout'
| 'path-team-page'
function isRevalidateMode(value: string): value is RevalidateMode {
return (
value === 'tag-layout-expireNow' ||
value === 'tag-layout-max' ||
value === 'tag-layout-legacy' ||
value === 'path-root-layout' ||
value === 'path-team-layout' ||
value === 'path-team-page'
)
}
export async function GET(request: NextRequest) {
const modeQuery = request.nextUrl.searchParams.get('mode')
const mode: RevalidateMode =
modeQuery && isRevalidateMode(modeQuery)
? modeQuery
: 'tag-layout-expireNow'
switch (mode) {
case 'tag-layout-expireNow':
revalidateTag('_N_T_/layout', 'expireNow')
break
case 'tag-layout-max':
revalidateTag('_N_T_/layout', 'max')
break
case 'tag-layout-legacy':
// Intentionally test the deprecated call shape without a profile arg.
// @ts-expect-error
revalidateTag('_N_T_/layout')
break
case 'path-root-layout':
revalidatePath('/', 'layout')
break
case 'path-team-layout':
revalidatePath('/acme/dashboard', 'layout')
break
case 'path-team-page':
revalidatePath('/acme/dashboard')
break
default:
break
}
return Response.json({
revalidated: true,
mode,
})
}