@@ -34,18 +34,21 @@ function getScriptAttributes(
3434}
3535
3636// Generate the build-scoped HTML entrypoint used by offline document fallback
37- // handling. It intentionally contains only the app bootstrap, not route HTML,
38- // so the artifact stays request-invariant.
37+ // handling. It intentionally contains only the app bootstrap, not route HTML;
38+ // route data is restored by the client from persisted router-cache records
39+ // after this document loads.
3940export function createOfflineNavigationFallbackDocument ( {
4041 assetPrefix,
4142 buildId,
4243 buildManifest,
4344 crossOrigin,
45+ deploymentId,
4446} : {
4547 assetPrefix : string
4648 buildId : string
4749 buildManifest : BuildManifest
4850 crossOrigin : '' | 'anonymous' | 'use-credentials' | undefined
51+ deploymentId : string | undefined
4952} ) : string | null {
5053 const rootMainFiles = buildManifest . rootMainFiles . filter ( ( file ) =>
5154 file . endsWith ( '.js' )
@@ -77,11 +80,15 @@ export function createOfflineNavigationFallbackDocument({
7780 source : 'offline-navigation-fallback' ,
7881 }
7982
83+ const deploymentIdAttribute = deploymentId
84+ ? ` data-dpl-id="${ htmlEscapeAttributeString ( deploymentId ) } "`
85+ : ''
86+
8087 return `<!DOCTYPE html><html data-next-offline-navigation-fallback="" data-build-id="${ htmlEscapeAttributeString (
8188 buildId
82- ) } "><head><meta charSet="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="next-offline-navigation-fallback" content="1"><meta name="next-build-id" content="${ htmlEscapeAttributeString (
89+ ) } "${ deploymentIdAttribute } ><head><meta charSet="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="next-offline-navigation-fallback" content="1"><meta name="next-build-id" content="${ htmlEscapeAttributeString (
8390 buildId
8491 ) } "><script id="__NEXT_OFFLINE_NAVIGATION_FALLBACK" type="application/json">${ htmlEscapeJsonString (
8592 JSON . stringify ( metadata )
86- ) } </script></head><body><div id="__next"></div><script>self.__next_f=self.__next_f||[];self.__next_f.push([0])</script>${ polyfillScripts } ${ bootstrapScripts } </body></html>`
93+ ) } </script></head><body><div id="__next"></div><p id="__NEXT_OFFLINE_NAVIGATION_CACHE_MISS" hidden>This page is not available offline.</p>< script>self.__next_f=self.__next_f||[];self.__next_f.push([0])</script>${ polyfillScripts } ${ bootstrapScripts } </body></html>`
8794}
0 commit comments