@@ -55,7 +55,7 @@ export function convertRedirectToRoutingRule(
5555 } ,
5656 apply : {
5757 type : 'redirect' ,
58- destination : fixDestinationGroupReplacements ( redirect . destination , redirect . sourceRegex ) ,
58+ destination : redirect . destination ,
5959 } ,
6060 } satisfies RoutingRuleRedirect
6161}
@@ -74,10 +74,7 @@ export function convertDynamicRouteToRoutingRule(
7474 } ,
7575 apply : {
7676 type : 'rewrite' ,
77- destination : fixDestinationGroupReplacements (
78- dynamicRoute . destination ,
79- dynamicRoute . sourceRegex ,
80- ) ,
77+ destination : dynamicRoute . destination ,
8178 rerunRoutingPhases : [ 'filesystem' , 'rewrite' ] , // this is attempt to mimic Vercel's check: true
8279 } ,
8380 } satisfies RoutingRuleRewrite
@@ -438,41 +435,62 @@ export async function generateRoutingRules(
438435 // apply x-nextjs-matched-path header and __next_data_catchall rewrite
439436 // if middleware + pages
440437
441- // { handle: 'hit' },
438+ {
439+ // originally: handle: 'hit' },
440+ // this is no-op on its own, it's just marker to be able to run subset of routing rules
441+ description : "'hit' routing phase marker" ,
442+ routingPhase : 'hit' ,
443+ continue : true ,
444+ } ,
442445
443446 // Before we handle static files we need to set proper caching headers
444- // {
445- // // This ensures we only match known emitted-by-Next.js files and not
446- // // user-emitted files which may be missing a hash in their filename.
447- // src: path.posix.join(
448- // '/',
449- // config.basePath,
450- // `_next/static/(?:[^/]+/pages|pages|chunks|runtime|css|image|media)/.+`,
451- // ),
452- // // Next.js assets contain a hash or entropy in their filenames, so they
453- // // are guaranteed to be unique and cacheable indefinitely.
454- // headers: {
455- // 'cache-control': `public,max-age=${MAX_AGE_ONE_YEAR},immutable`,
456- // },
457- // continue: true,
458- // important: true,
459- // },
460- // {
461- // src: path.posix.join('/', config.basePath, '/index(?:/)?'),
462- // headers: {
463- // 'x-matched-path': '/',
464- // },
465- // continue: true,
466- // important: true,
467- // },
468- // {
469- // src: path.posix.join('/', config.basePath, `/((?!index$).*?)(?:/)?`),
470- // headers: {
471- // 'x-matched-path': '/$1',
472- // },
473- // continue: true,
474- // important: true,
475- // },
447+ {
448+ // This ensures we only match known emitted-by-Next.js files and not
449+ // user-emitted files which may be missing a hash in their filename.
450+ description : 'Ensure static files caching headers' ,
451+ match : {
452+ path : join (
453+ '/' ,
454+ nextAdapterContext . config . basePath || '' ,
455+ `_next/static/(?:[^/]+/pages|pages|chunks|runtime|css|image|media|${ nextAdapterContext . buildId } )/.+` ,
456+ ) ,
457+ } ,
458+ apply : {
459+ type : 'apply' ,
460+ // Next.js assets contain a hash or entropy in their filenames, so they
461+ // are guaranteed to be unique and cacheable indefinitely.
462+ headers : {
463+ 'cache-control' : 'public,max-age=31536000,immutable' ,
464+ } ,
465+ } ,
466+ continue : true ,
467+ } ,
468+ {
469+ description : 'Apply x-matched-path header if index' ,
470+ match : {
471+ path : join ( '^/' , nextAdapterContext . config . basePath , '/index(?:/)?$' ) ,
472+ } ,
473+ apply : {
474+ type : 'apply' ,
475+ headers : {
476+ 'x-matched-path' : '/' ,
477+ } ,
478+ } ,
479+ continue : true ,
480+ } ,
481+ {
482+ description : 'Apply x-matched-path header if not index' ,
483+ match : {
484+ path : join ( '^/' , nextAdapterContext . config . basePath , '/((?!index$).*?)(?:/)?$' ) ,
485+ } ,
486+ apply : {
487+ type : 'apply' ,
488+ headers : {
489+ 'x-matched-path' : '/$1' ,
490+ } ,
491+ } ,
492+ continue : true ,
493+ } ,
476494
477495 // { handle: 'error' },
478496
0 commit comments