vinext 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +6 -3
- package/dist/deploy.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +179 -10
- package/dist/index.js.map +1 -1
- package/dist/routing/app-router.d.ts.map +1 -1
- package/dist/routing/app-router.js +1 -41
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/pages-router.d.ts.map +1 -1
- package/dist/routing/pages-router.js +1 -27
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/routing/utils.d.ts +25 -0
- package/dist/routing/utils.d.ts.map +1 -0
- package/dist/routing/utils.js +70 -0
- package/dist/routing/utils.js.map +1 -0
- package/dist/server/app-dev-server.d.ts.map +1 -1
- package/dist/server/app-dev-server.js +70 -3
- package/dist/server/app-dev-server.js.map +1 -1
- package/dist/server/dev-server.d.ts.map +1 -1
- package/dist/server/dev-server.js +77 -4
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/prod-server.d.ts.map +1 -1
- package/dist/server/prod-server.js +7 -0
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-log.d.ts +34 -0
- package/dist/server/request-log.d.ts.map +1 -0
- package/dist/server/request-log.js +65 -0
- package/dist/server/request-log.js.map +1 -0
- package/dist/shims/cache-runtime.d.ts.map +1 -1
- package/dist/shims/cache-runtime.js +5 -1
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +6 -0
- package/dist/shims/cache.d.ts.map +1 -1
- package/dist/shims/cache.js +22 -2
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/head.d.ts +11 -0
- package/dist/shims/head.d.ts.map +1 -1
- package/dist/shims/head.js +21 -0
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +8 -0
- package/dist/shims/headers.d.ts.map +1 -1
- package/dist/shims/headers.js +41 -0
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/script.d.ts.map +1 -1
- package/dist/shims/script.js +7 -1
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.d.ts.map +1 -1
- package/dist/shims/server.js +2 -1
- package/dist/shims/server.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/server/dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/server/dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AA+K/D;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,cAAc,GACzB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAYrD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,eAAe,EACpB,UAAU,EAAE,cAAc,GACzB,MAAM,GAAG,IAAI,CA4Bf;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,eAAe,EACpB,UAAU,EAAE,cAAc,GACzB,MAAM,GAAG,IAAI,CAiBf;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,KAAK,EAAE,EACf,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,cAAc,GAAG,IAAI,IAGhC,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,MAAM;AACX,wEAAwE;AACxE,aAAa,MAAM,KAClB,OAAO,CAAC,IAAI,CAAC,CAslBjB"}
|
|
@@ -14,6 +14,7 @@ import path from "node:path";
|
|
|
14
14
|
import fs from "node:fs";
|
|
15
15
|
import React from "react";
|
|
16
16
|
import { renderToReadableStream } from "react-dom/server.edge";
|
|
17
|
+
import { logRequest, now } from "./request-log.js";
|
|
17
18
|
const PAGE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
|
|
18
19
|
/**
|
|
19
20
|
* Render a React element to a string using renderToReadableStream.
|
|
@@ -88,12 +89,24 @@ async function streamPageToResponse(res, element, options) {
|
|
|
88
89
|
const markerIdx = transformedShell.indexOf(STREAM_BODY_MARKER);
|
|
89
90
|
const prefix = transformedShell.slice(0, markerIdx);
|
|
90
91
|
const suffix = transformedShell.slice(markerIdx + STREAM_BODY_MARKER.length);
|
|
91
|
-
// Send headers and start streaming
|
|
92
|
+
// Send headers and start streaming.
|
|
93
|
+
// Set array-valued headers (e.g. Set-Cookie from gSSP) via setHeader()
|
|
94
|
+
// before writeHead(), since writeHead()'s headers object doesn't handle
|
|
95
|
+
// arrays portably. Then writeHead() merges with any setHeader() calls.
|
|
92
96
|
const headers = {
|
|
93
97
|
"Content-Type": "text/html",
|
|
94
98
|
"Transfer-Encoding": "chunked",
|
|
95
|
-
...extraHeaders,
|
|
96
99
|
};
|
|
100
|
+
if (extraHeaders) {
|
|
101
|
+
for (const [key, val] of Object.entries(extraHeaders)) {
|
|
102
|
+
if (Array.isArray(val)) {
|
|
103
|
+
res.setHeader(key, val);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
headers[key] = val;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
97
110
|
res.writeHead(statusCode, headers);
|
|
98
111
|
// Write the document prefix (head, opening body)
|
|
99
112
|
res.write(prefix);
|
|
@@ -201,6 +214,26 @@ export function createSSRHandler(server, routes, pagesDir, i18nConfig) {
|
|
|
201
214
|
return async (req, res, url,
|
|
202
215
|
/** Status code override — propagated from middleware rewrite status. */
|
|
203
216
|
statusCode) => {
|
|
217
|
+
const _reqStart = now();
|
|
218
|
+
let _compileEnd;
|
|
219
|
+
let _renderEnd;
|
|
220
|
+
res.on("finish", () => {
|
|
221
|
+
const totalMs = now() - _reqStart;
|
|
222
|
+
const compileMs = _compileEnd !== undefined ? Math.round(_compileEnd - _reqStart) : undefined;
|
|
223
|
+
// renderMs = time from end of compile to end of stream.
|
|
224
|
+
// _renderEnd is set just after streamPageToResponse resolves.
|
|
225
|
+
const renderMs = _renderEnd !== undefined && _compileEnd !== undefined
|
|
226
|
+
? Math.round(_renderEnd - _compileEnd)
|
|
227
|
+
: undefined;
|
|
228
|
+
logRequest({
|
|
229
|
+
method: req.method ?? "GET",
|
|
230
|
+
url,
|
|
231
|
+
status: res.statusCode,
|
|
232
|
+
totalMs,
|
|
233
|
+
compileMs,
|
|
234
|
+
renderMs,
|
|
235
|
+
});
|
|
236
|
+
});
|
|
204
237
|
// --- i18n: extract locale from URL prefix ---
|
|
205
238
|
let locale;
|
|
206
239
|
let localeStrippedUrl = url;
|
|
@@ -263,6 +296,8 @@ export function createSSRHandler(server, routes, pagesDir, i18nConfig) {
|
|
|
263
296
|
// Load the page module through Vite's SSR pipeline
|
|
264
297
|
// This gives us HMR and transform support for free
|
|
265
298
|
const pageModule = await server.ssrLoadModule(route.filePath);
|
|
299
|
+
// Mark end of compile phase: everything from here is rendering.
|
|
300
|
+
_compileEnd = now();
|
|
266
301
|
// Get the page component (default export)
|
|
267
302
|
const PageComponent = pageModule.default;
|
|
268
303
|
if (!PageComponent) {
|
|
@@ -305,7 +340,14 @@ export function createSSRHandler(server, routes, pagesDir, i18nConfig) {
|
|
|
305
340
|
// The difference is that fallback:true could serve a shell first,
|
|
306
341
|
// but since we always have data available via SSR, we render fully.
|
|
307
342
|
}
|
|
343
|
+
// Headers set by getServerSideProps for explicit forwarding to
|
|
344
|
+
// streamPageToResponse. Without this, they survive only through
|
|
345
|
+
// Node.js writeHead() implicitly merging setHeader() calls, which
|
|
346
|
+
// would silently break if streamPageToResponse is refactored.
|
|
347
|
+
const gsspExtraHeaders = {};
|
|
308
348
|
if (typeof pageModule.getServerSideProps === "function") {
|
|
349
|
+
// Snapshot existing headers so we can detect what gSSP adds.
|
|
350
|
+
const headersBeforeGSSP = new Set(Object.keys(res.getHeaders()));
|
|
309
351
|
const context = {
|
|
310
352
|
params,
|
|
311
353
|
req,
|
|
@@ -317,6 +359,16 @@ export function createSSRHandler(server, routes, pagesDir, i18nConfig) {
|
|
|
317
359
|
defaultLocale: i18nConfig?.defaultLocale,
|
|
318
360
|
};
|
|
319
361
|
const result = await pageModule.getServerSideProps(context);
|
|
362
|
+
// If gSSP called res.end() directly (short-circuit pattern),
|
|
363
|
+
// the response is already sent. Do not continue rendering.
|
|
364
|
+
// Note: middleware headers are already on `res` (middleware runs
|
|
365
|
+
// before this handler in the connect chain), so they are included
|
|
366
|
+
// in the short-circuited response. The prod path achieves the same
|
|
367
|
+
// result via the worker entry merging middleware headers after
|
|
368
|
+
// renderPage() returns.
|
|
369
|
+
if (res.writableEnded) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
320
372
|
if (result && "props" in result) {
|
|
321
373
|
pageProps = result.props;
|
|
322
374
|
}
|
|
@@ -339,6 +391,25 @@ export function createSSRHandler(server, routes, pagesDir, i18nConfig) {
|
|
|
339
391
|
await renderErrorPage(server, req, res, url, pagesDir, 404, routerShim.wrapWithRouterContext);
|
|
340
392
|
return;
|
|
341
393
|
}
|
|
394
|
+
// Preserve any status code set by gSSP (e.g. res.statusCode = 201).
|
|
395
|
+
// This takes precedence over the default 200 but not over middleware status.
|
|
396
|
+
if (!statusCode && res.statusCode !== 200) {
|
|
397
|
+
statusCode = res.statusCode;
|
|
398
|
+
}
|
|
399
|
+
// Capture headers newly set by gSSP and forward them explicitly.
|
|
400
|
+
// Remove from `res` to prevent duplication when writeHead() merges.
|
|
401
|
+
const headersAfterGSSP = res.getHeaders();
|
|
402
|
+
for (const [key, val] of Object.entries(headersAfterGSSP)) {
|
|
403
|
+
if (headersBeforeGSSP.has(key) || val == null)
|
|
404
|
+
continue;
|
|
405
|
+
res.removeHeader(key);
|
|
406
|
+
if (Array.isArray(val)) {
|
|
407
|
+
gsspExtraHeaders[key] = val.map(String);
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
gsspExtraHeaders[key] = String(val);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
342
413
|
}
|
|
343
414
|
// Collect font preloads early so ISR cached responses can include
|
|
344
415
|
// the Link header (font preloads are module-level state that persists
|
|
@@ -605,8 +676,9 @@ hydrate();
|
|
|
605
676
|
}
|
|
606
677
|
}
|
|
607
678
|
const allScripts = `${nextDataScript}\n ${hydrationScript}`;
|
|
608
|
-
// Build
|
|
609
|
-
|
|
679
|
+
// Build response headers: start with gSSP headers, then layer on
|
|
680
|
+
// ISR and font preload headers (which take precedence).
|
|
681
|
+
const extraHeaders = { ...gsspExtraHeaders };
|
|
610
682
|
if (isrRevalidateSeconds) {
|
|
611
683
|
extraHeaders["Cache-Control"] = `s-maxage=${isrRevalidateSeconds}, stale-while-revalidate`;
|
|
612
684
|
extraHeaders["X-Vinext-Cache"] = "MISS";
|
|
@@ -636,6 +708,7 @@ hydrate();
|
|
|
636
708
|
? headShim.getSSRHeadHTML()
|
|
637
709
|
: "",
|
|
638
710
|
});
|
|
711
|
+
_renderEnd = now();
|
|
639
712
|
// Clear SSR context after rendering
|
|
640
713
|
if (typeof routerShim.setSSRContext === "function") {
|
|
641
714
|
routerSh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","sourcesContent":["import type { ViteDevServer } from \"vite\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport type { Route } from \"../routing/pages-router.js\";\nimport { matchRoute, patternToNextFormat } from \"../routing/pages-router.js\";\nimport type { NextI18nConfig } from \"../config/next-config.js\";\nimport {\n isrGet,\n isrSet,\n isrCacheKey,\n buildPagesCacheValue,\n triggerBackgroundRegeneration,\n setRevalidateDuration,\n getRevalidateDuration,\n} from \"./isr-cache.js\";\nimport type { CachedPagesValue } from \"../shims/cache.js\";\nimport { runWithFetchCache } from \"../shims/fetch-cache.js\";\nimport { _runWithCacheState } from \"../shims/cache.js\";\nimport { runWithPrivateCache } from \"../shims/cache-runtime.js\";\n// Import server-only state modules to register ALS-backed accessors.\n// These modules must be imported before any rendering occurs.\nimport { runWithRouterState } from \"../shims/router-state.js\";\nimport { runWithHeadState } from \"../shims/head-state.js\";\nimport { reportRequestError } from \"./instrumentation.js\";\nimport { safeJsonStringify } from \"./html.js\";\nimport { parseQueryString as parseQuery } from \"../utils/query.js\";\nimport path from \"node:path\";\nimport fs from \"node:fs\";\nimport React from \"react\";\nimport { renderToReadableStream } from \"react-dom/server.edge\";\n\nconst PAGE_EXTENSIONS = [\".tsx\", \".ts\", \".jsx\", \".js\"];\n\n/**\n * Render a React element to a string using renderToReadableStream.\n *\n * Uses the edge-compatible Web Streams API. Waits for all Suspense\n * boundaries to resolve via stream.allReady before collecting output.\n * Used for _document rendering and error pages (small, non-streaming).\n */\nasync function renderToStringAsync(element: React.ReactElement): Promise<string> {\n const stream = await renderToReadableStream(element);\n await stream.allReady;\n return new Response(stream).text();\n}\n\n/** Body placeholder used to split the document shell for streaming. */\nconst STREAM_BODY_MARKER = \"<!--VINEXT_STREAM_BODY-->\";\n\n/**\n * Stream a Pages Router page response using progressive SSR.\n *\n * Sends the HTML shell (head, layout, Suspense fallbacks) immediately\n * when the React shell is ready, then streams Suspense content as it\n * resolves. This gives the browser content to render while slow data\n * loads are still in flight.\n *\n * `__NEXT_DATA__` and the hydration script are appended after the body\n * stream completes (the data is known before rendering starts, but\n * deferring them reduces TTFB and lets the browser start parsing the\n * shell sooner).\n */\nasync function streamPageToResponse(\n res: ServerResponse,\n element: React.ReactElement,\n options: {\n url: string;\n server: ViteDevServer;\n fontHeadHTML: string;\n scripts: string;\n DocumentComponent: React.ComponentType | null;\n statusCode?: number;\n extraHeaders?: Record<string, string>;\n /** Called after renderToReadableStream resolves (shell ready) to collect head HTML */\n getHeadHTML: () => string;\n },\n): Promise<void> {\n const {\n url,\n server,\n fontHeadHTML,\n scripts,\n DocumentComponent,\n statusCode = 200,\n extraHeaders,\n getHeadHTML,\n } = options;\n\n // Start the React body stream FIRST — the promise resolves when the\n // shell is ready (synchronous content outside Suspense boundaries).\n // This triggers the render which populates <Head> tags.\n const bodyStream = await renderToReadableStream(element);\n\n // Now that the shell has rendered, collect head HTML\n const headHTML = getHeadHTML();\n\n // Build the document shell with a placeholder for the body\n let shellTemplate: string;\n\n if (DocumentComponent) {\n const docElement = React.createElement(DocumentComponent);\n let docHtml = await renderToStringAsync(docElement);\n // Replace __NEXT_MAIN__ with our stream marker\n docHtml = docHtml.replace(\"__NEXT_MAIN__\", STREAM_BODY_MARKER);\n // Inject head tags\n if (headHTML || fontHeadHTML) {\n docHtml = docHtml.replace(\"</head>\", ` ${fontHeadHTML}${headHTML}\\n</head>`);\n }\n // Inject scripts: replace placeholder or append before </body>\n docHtml = docHtml.replace(\"<!-- __NEXT_SCRIPTS__ -->\", scripts);\n if (!docHtml.includes(\"__NEXT_DATA__\")) {\n docHtml = docHtml.replace(\"</body>\", ` ${scripts}\\n</body>`);\n }\n shellTemplate = docHtml;\n } else {\n shellTemplate = `<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n ${fontHeadHTML}${headHTML}\n</head>\n<body>\n <div id=\"__next\">${STREAM_BODY_MARKER}</div>\n ${scripts}\n</body>\n</html>`;\n }\n\n // Apply Vite's HTML transforms (injects HMR client, etc.) on the full\n // shell template, then split at the body marker.\n const transformedShell = await server.transformIndexHtml(url, shellTemplate);\n const markerIdx = transformedShell.indexOf(STREAM_BODY_MARKER);\n const prefix = transformedShell.slice(0, markerIdx);\n const suffix = transformedShell.slice(markerIdx + STREAM_BODY_MARKER.length);\n\n // Send headers and start streaming\n const headers: Record<string, string> = {\n \"Content-Type\": \"text/html\",\n \"Transfer-Encoding\": \"chunked\",\n ...extraHeaders,\n };\n res.writeHead(statusCode, headers);\n\n // Write the document prefix (head, opening body)\n res.write(prefix);\n\n // Pipe the React body stream through (Suspense content streams progressively)\n const reader = bodyStream.getReader();\n try {\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n res.write(value);\n }\n } finally {\n reader.releaseLock();\n }\n\n // Write the document suffix (closing tags, scripts)\n res.end(suffix);\n}\n\n/** Check if a file exists with any page extension (tsx, ts, jsx, js). */\nfunction findFileWithExtensions(basePath: string): boolean {\n return PAGE_EXTENSIONS.some((ext) => fs.existsSync(basePath + ext));\n}\n\n/**\n * Extract locale prefix from a URL path.\n * e.g. /fr/about -> { locale: \"fr\", url: \"/about\", hadPrefix: true }\n * /about -> { locale: \"en\", url: \"/about\", hadPrefix: false } (defaultLocale)\n */\nexport function extractLocaleFromUrl(\n url: string,\n i18nConfig: NextI18nConfig,\n): { locale: string; url: string; hadPrefix: boolean } {\n const pathname = url.split(\"?\")[0];\n const parts = pathname.split(\"/\").filter(Boolean);\n const query = url.includes(\"?\") ? url.slice(url.indexOf(\"?\")) : \"\";\n\n if (parts.length > 0 && i18nConfig.locales.includes(parts[0])) {\n const locale = parts[0];\n const rest = \"/\" + parts.slice(1).join(\"/\");\n return { locale, url: (rest || \"/\") + query, hadPrefix: true };\n }\n\n return { locale: i18nConfig.defaultLocale, url, hadPrefix: false };\n}\n\n/**\n * Detect the preferred locale from the Accept-Language header.\n * Returns the best matching locale or null.\n */\nexport function detectLocaleFromHeaders(\n req: IncomingMessage,\n i18nConfig: NextI18nConfig,\n): string | null {\n const acceptLang = req.headers[\"accept-language\"];\n if (!acceptLang) return null;\n\n // Parse Accept-Language: en-US,en;q=0.9,fr;q=0.8\n const langs = acceptLang\n .split(\",\")\n .map((part) => {\n const [lang, qPart] = part.trim().split(\";\");\n const q = qPart ? parseFloat(qPart.replace(\"q=\", \"\")) : 1;\n return { lang: lang.trim().toLowerCase(), q };\n })\n .sort((a, b) => b.q - a.q);\n\n for (const { lang } of langs) {\n // Exact match\n const exactMatch = i18nConfig.locales.find((l) => l.toLowerCase() === lang);\n if (exactMatch) return exactMatch;\n\n // Prefix match (e.g. \"en-US\" matches \"en\")\n const prefix = lang.split(\"-\")[0];\n const prefixMatch = i18nConfig.locales.find(\n (l) => l.toLowerCase() === prefix || l.toLowerCase().startsWith(prefix + \"-\"),\n );\n if (prefixMatch) return prefixMatch;\n }\n\n return null;\n}\n\n/**\n * Parse the NEXT_LOCALE cookie from a request.\n * Returns the cookie value if it matches a configured locale, otherwise null.\n */\nexport function parseCookieLocale(\n req: IncomingMessage,\n i18nConfig: NextI18nConfig,\n): string | null {\n const cookieHeader = req.headers.cookie;\n if (!cookieHeader) return null;\n\n // Simple cookie parsing — find NEXT_LOCALE=value\n const match = cookieHeader.match(/(?:^|;\\s*)NEXT_LOCALE=([^;]*)/);\n if (!match) return null;\n\n let value: string;\n try {\n value = decodeURIComponent(match[1].trim());\n } catch {\n return null;\n }\n // Only return if it's a valid configured locale\n if (i18nConfig.locales.includes(value)) return value;\n return null;\n}\n\n/**\n * Create an SSR request handler for the Pages Router.\n *\n * For each request:\n * 1. Match the URL against discovered routes\n * 2. Load the page module via Vite's SSR module loader\n * 3. Call getServerSideProps/getStaticProps if present\n * 4. Render the component to HTML\n * 5. Wrap in _document shell and send response\n */\nexport function createSSRHandler(\n server: ViteDevServer,\n routes: Route[],\n pagesDir: string,\n i18nConfig?: NextI18nConfig | null,\n) {\n return async (\n req: IncomingMessage,\n res: ServerResponse,\n url: string,\n /** Status code override — propagated from middleware rewrite status. */\n statusCode?: number,\n ): Promise<void> => {\n // --- i18n: extract locale from URL prefix ---\n let locale: string | undefined;\n let localeStrippedUrl = url;\n\n if (i18nConfig) {\n const parsed = extractLocaleFromUrl(url, i18nConfig);\n locale = parsed.locale;\n localeStrippedUrl = parsed.url;\n\n // If no locale prefix, check NEXT_LOCALE cookie first, then Accept-Language\n if (!parsed.hadPrefix) {\n const cookieLocale = parseCookieLocale(req, i18nConfig);\n if (cookieLocale && cookieLocale !== i18nConfig.defaultLocale) {\n // NEXT_LOCALE cookie overrides Accept-Language — redirect to cookie locale\n const redirectUrl = `/${cookieLocale}${url === \"/\" ? \"\" : url}`;\n res.writeHead(307, { Location: redirectUrl });\n res.end();\n return;\n }\n // If no cookie or cookie matches default, fall through to Accept-Language detection\n if (!cookieLocale && i18nConfig.localeDetection !== false) {\n const detectedLocale = detectLocaleFromHeaders(req, i18nConfig);\n if (detectedLocale && detectedLocale !== i18nConfig.defaultLocale) {\n const redirectUrl = `/${detectedLocale}${url === \"/\" ? \"\" : url}`;\n res.writeHead(307, { Location: redirectUrl });\n res.end();\n return;\n }\n }\n }\n }\n\n const match = matchRoute(localeStrippedUrl, routes);\n\n if (!match) {\n // No route matched — try to render custom 404 page\n await renderErrorPage(server, req, res, url, pagesDir, 404);\n return;\n }\n\n const { route, params } = match;\n\n // Wrap the entire request in nested AsyncLocalStorage.run() scopes to\n // ensure per-request isolation for all state modules.\n return runWithRouterState(() =>\n runWithHeadState(() =>\n _runWithCacheState(() =>\n runWithPrivateCache(() =>\n runWithFetchCache(async () => {\n try {\n // Set SSR context for the router shim so useRouter() returns\n // the correct URL and params during server-side rendering.\n const routerShim = await server.ssrLoadModule(\"next/router\");\n if (typeof routerShim.setSSRContext === \"function\") {\n routerShim.setSSRContext({\n pathname: localeStrippedUrl.split(\"?\")[0],\n query: { ...params, ...parseQuery(url) },\n asPath: url,\n locale: locale ?? i18nConfig?.defaultLocale,\n locales: i18nConfig?.locales,\n defaultLocale: i18nConfig?.defaultLocale,\n });\n }\n\n // Set globalThis locale info for Link component locale prop support during SSR\n if (i18nConfig) {\n (globalThis as any).__VINEXT_LOCALE__ = locale ?? i18nConfig.defaultLocale;\n (globalThis as any).__VINEXT_LOCALES__ = i18nConfig.locales;\n (globalThis as any).__VINEXT_DEFAULT_LOCALE__ = i18nConfig.defaultLocale;\n }\n\n // Load the page module through Vite's SSR pipeline\n // This gives us HMR and transform support for free\n const pageModule = await server.ssrLoadModule(route.filePath);\n\n // Get the page component (default export)\n const PageComponent = pageModule.default;\n if (!PageComponent) {\n console.error(`[vinext] Page ${route.filePath} has no default export`);\n res.statusCode = 500;\n res.end(\"Page has no default export\");\n return;\n }\n\n // Collect page props via data fetching methods\n let pageProps: Record<string, unknown> = {};\n let isrRevalidateSeconds: number | null = null;\n\n // Handle getStaticPaths for dynamic routes: validate the path\n // and respect fallback: false (return 404 for unlisted paths).\n if (typeof pageModule.getStaticPaths === \"function\" && route.isDynamic) {\n const pathsResult = await pageModule.getStaticPaths({\n locales: i18nConfig?.locales ?? [],\n defaultLocale: i18nConfig?.defaultLocale ?? \"\",\n });\n const fallback = pathsResult?.fallback ?? false;\n\n if (fallback === false) {\n // Only allow paths explicitly listed in getStaticPaths\n const paths: Array<{ params: Record<string, string | string[]> }> =\n pathsResult?.paths ?? [];\n const isValidPath = paths.some((p: { params: Record<string, string | string[]> }) => {\n return Object.entries(p.params).every(([key, val]) => {\n const actual = params[key];\n if (Array.isArray(val)) {\n return Array.isArray(actual) && val.join(\"/\") === actual.join(\"/\");\n }\n return String(val) === String(actual);\n });\n });\n\n if (!isValidPath) {\n await renderErrorPage(server, req, res, url, pagesDir, 404, routerShim.wrapWithRouterContext);\n return;\n }\n }\n // fallback: true or \"blocking\" — always SSR on-demand.\n // In dev mode, Next.js does the same (no fallback shell).\n // In production, both modes SSR on-demand with caching.\n // The difference is that fallback:true could serve a shell first,\n // but since we always have data available via SSR, we render fully.\n }\n\n if (typeof pageModule.getServerSideProps === \"function\") {\n const context = {\n params,\n req,\n res,\n query: parseQuery(url),\n resolvedUrl: localeStrippedUrl,\n locale: locale ?? i18nConfig?.defaultLocale,\n locales: i18nConfig?.locales,\n defaultLocale: i18nConfig?.defaultLocale,\n };\n const result = await pageModule.getServerSideProps(context);\n if (result && \"props\" in result) {\n pageProps = result.props;\n }\n if (result && \"redirect\" in result) {\n const { redirect } = result;\n const status = redirect.statusCode ?? (redirect.permanent ? 308 : 307);\n // Sanitize destination to prevent open redirect via protocol-relative URLs.\n // Also normalize backslashes — browsers treat \\ as / in URL contexts.\n let dest = redirect.destination;\n if (!dest.startsWith(\"http://\") && !dest.startsWith(\"https://\")) {\n dest = dest.replace(/^[\\\\/]+/, \"/\");\n }\n res.writeHead(status, {\n Location: dest,\n });\n res.end();\n return;\n }\n if (result && \"notFound\" in result && result.notFound) {\n await renderErrorPage(server, req, res, url, pagesDir, 404, routerShim.wrapWithRouterContext);\n return;\n }\n }\n // Collect font preloads early so ISR cached responses can include\n // the Link header (font preloads are module-level state that persists\n // across requests after the font modules are first loaded).\n let earlyFontLinkHeader = \"\";\n try {\n const earlyPreloads: Array<{ href: string; type: string }> = [];\n const fontGoogleEarly = await server.ssrLoadModule(\"next/font/google\");\n if (typeof fontGoogleEarly.getSSRFontPreloads === \"function\") {\n earlyPreloads.push(...fontGoogleEarly.getSSRFontPreloads());\n }\n const fontLocalEarly = await server.ssrLoadModule(\"next/font/local\");\n if (typeof fontLocalEarly.getSSRFontPreloads === \"function\") {\n earlyPreloads.push(...fontLocalEarly.getSSRFontPreloads());\n }\n if (earlyPreloads.length > 0) {\n earlyFontLinkHeader = earlyPreloads\n .map((p) => `<${p.href}>; rel=preload; as=font; type=${p.type}; crossorigin`)\n .join(\", \");\n }\n } catch {\n // Font modules not loaded yet — skip\n }\n\n if (typeof pageModule.getStaticProps === \"function\") {\n // Check ISR cache before calling getStaticProps\n const cacheKey = isrCacheKey(\"pages\", url.split(\"?\")[0]);\n const cached = await isrGet(cacheKey);\n\n if (cached && !cached.isStale && cached.value.value?.kind === \"PAGES\") {\n // Fresh cache hit — serve directly\n const cachedPage = cached.value.value as CachedPagesValue;\n const cachedHtml = cachedPage.html;\n const transformedHtml = await server.transformIndexHtml(url, cachedHtml);\n const revalidateSecs = getRevalidateDuration(cacheKey) ?? 60;\n const hitHeaders: Record<string, string> = {\n \"Content-Type\": \"text/html\",\n \"X-Vinext-Cache\": \"HIT\",\n \"Cache-Control\": `s-maxage=${revalidateSecs}, stale-while-revalidate`,\n };\n if (earlyFontLinkHeader) hitHeaders[\"Link\"] = earlyFontLinkHeader;\n res.writeHead(200, hitHeaders);\n res.end(transformedHtml);\n return;\n }\n\n if (cached && cached.isStale && cached.value.value?.kind === \"PAGES\") {\n // Stale hit — serve stale immediately, trigger background regen\n const cachedPage = cached.value.value as CachedPagesValue;\n const cachedHtml = cachedPage.html;\n const transformedHtml = await server.transformIndexHtml(url, cachedHtml);\n\n // Trigger background regeneration: re-run getStaticProps and\n // update the cache so the next request is a HIT with fresh data.\n triggerBackgroundRegeneration(cacheKey, async () => {\n const freshResult = await pageModule.getStaticProps({ params });\n if (freshResult && \"props\" in freshResult) {\n const revalidate = typeof freshResult.revalidate === \"number\" ? freshResult.revalidate : 0;\n if (revalidate > 0) {\n await isrSet(cacheKey, buildPagesCacheValue(cachedHtml, freshResult.props), revalidate);\n }\n }\n });\n\n const revalidateSecs = getRevalidateDuration(cacheKey) ?? 60;\n const staleHeaders: Record<string, string> = {\n \"Content-Type\": \"text/html\",\n \"X-Vinext-Cache\": \"STALE\",\n \"Cache-Control\": `s-maxage=${revalidateSecs}, stale-while-revalidate`,\n };\n if (earlyFontLinkHeader) staleHeaders[\"Link\"] = earlyFontLinkHeader;\n res.writeHead(200, staleHeaders);\n res.end(transformedHtml);\n return;\n }\n\n // Cache miss — call getStaticProps normally\n const context = {\n params,\n locale: locale ?? i18nConfig?.defaultLocale,\n locales: i18nConfig?.locales,\n defaultLocale: i18nConfig?.defaultLocale,\n };\n const result = await pageModule.getStaticProps(context);\n if (result && \"props\" in result) {\n pageProps = result.props;\n }\n if (result && \"redirect\" in result) {\n const { redirect } = result;\n const status = redirect.statusCode ?? (redirect.permanent ? 308 : 307);\n // Sanitize destination to prevent open redirect via protocol-relative URLs.\n // Also normalize backslashes — browsers treat \\ as / in URL contexts.\n let dest = redirect.destination;\n if (!dest.startsWith(\"http://\") && !dest.startsWith(\"https://\")) {\n dest = dest.replace(/^[\\\\/]+/, \"/\");\n }\n res.writeHead(status, {\n Location: dest,\n });\n res.end();\n return;\n }\n if (result && \"notFound\" in result && result.notFound) {\n await renderErrorPage(server, req, res, url, pagesDir, 404, routerShim.wrapWithRouterContext);\n return;\n }\n\n // Extract revalidate period for ISR caching after render\n if (typeof result?.revalidate === \"number\" && result.revalidate > 0) {\n isrRevalidateSeconds = result.revalidate;\n }\n }\n\n // Try to load _app.tsx if it exists\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let AppComponent: any = null;\n const appPath = path.join(pagesDir, \"_app\");\n if (findFileWithExtensions(appPath)) {\n try {\n const appModule = await server.ssrLoadModule(appPath);\n AppComponent = appModule.default ?? null;\n } catch {\n // _app exists but failed to load\n }\n }\n\n // React and ReactDOMServer are imported at the top level as native Node\n // modules. They must NOT go through Vite's SSR module runner because\n // React is CJS and the ESModulesEvaluator doesn't define `module`.\n const createElement = React.createElement;\n let element: React.ReactElement;\n\n // wrapWithRouterContext wraps the element in RouterContext.Provider so that\n // next/compat/router's useRouter() returns the real router.\n const wrapWithRouterContext = routerShim.wrapWithRouterContext;\n\n if (AppComponent) {\n element = createElement(AppComponent, {\n Component: PageComponent,\n pageProps,\n });\n } else {\n element = createElement(PageComponent, pageProps);\n }\n\n if (wrapWithRouterContext) {\n element = wrapWithRouterContext(element);\n }\n\n // Reset SSR head collector before rendering so <Head> tags are captured\n const headShim = await server.ssrLoadModule(\"next/head\");\n if (typeof headShim.resetSSRHead === \"function\") {\n headShim.resetSSRHead();\n }\n\n // Flush any pending dynamic() preloads so components are ready\n const dynamicShim = await server.ssrLoadModule(\"next/dynamic\");\n if (typeof dynamicShim.flushPreloads === \"function\") {\n await dynamicShim.flushPreloads();\n }\n\n // Collect any <Head> tags that were rendered during data fetching\n // (shell head tags — Suspense children's head tags arrive late,\n // matching Next.js behavior)\n\n // Collect SSR font links (Google Fonts <link> tags) and font class styles\n let fontHeadHTML = \"\";\n const allFontStyles: string[] = [];\n const allFontPreloads: Array<{ href: string; type: string }> = [];\n try {\n const fontGoogle = await server.ssrLoadModule(\"next/font/google\");\n if (typeof fontGoogle.getSSRFontLinks === \"function\") {\n const fontUrls = fontGoogle.getSSRFontLinks();\n for (const fontUrl of fontUrls) {\n const safeFontUrl = fontUrl.replace(/&/g, \"&\").replace(/\"/g, \""\");\n fontHeadHTML += `<link rel=\"stylesheet\" href=\"${safeFontUrl}\" />\\n `;\n }\n }\n if (typeof fontGoogle.getSSRFontStyles === \"function\") {\n allFontStyles.push(...fontGoogle.getSSRFontStyles());\n }\n // Collect preloads from self-hosted Google fonts\n if (typeof fontGoogle.getSSRFontPreloads === \"function\") {\n allFontPreloads.push(...fontGoogle.getSSRFontPreloads());\n }\n } catch {\n // next/font/google not used — skip\n }\n try {\n const fontLocal = await server.ssrLoadModule(\"next/font/local\");\n if (typeof fontLocal.getSSRFontStyles === \"function\") {\n allFontStyles.push(...fontLocal.getSSRFontStyles());\n }\n // Collect preloads from local font files\n if (typeof fontLocal.getSSRFontPreloads === \"function\") {\n allFontPreloads.push(...fontLocal.getSSRFontPreloads());\n }\n } catch {\n // next/font/local not used — skip\n }\n // Emit <link rel=\"preload\"> for all collected font files (Google + local)\n for (const { href, type } of allFontPreloads) {\n // Escape href/type to prevent HTML attribute injection (defense-in-depth;\n // Vite-resolved asset paths should never contain special chars).\n const safeHref = href.replace(/&/g, \"&\").replace(/\"/g, \""\");\n const safeType = type.replace(/&/g, \"&\").replace(/\"/g, \""\");\n fontHeadHTML += `<link rel=\"preload\" href=\"${safeHref}\" as=\"font\" type=\"${safeType}\" crossorigin />\\n `;\n }\n if (allFontStyles.length > 0) {\n fontHeadHTML += `<style data-vinext-fonts>${allFontStyles.join(\"\\n\")}</style>\\n `;\n }\n\n // Convert absolute file paths to Vite-servable URLs (relative to root)\n const viteRoot = server.config.root;\n const pageModuleUrl = \"/\" + path.relative(viteRoot, route.filePath);\n const appModuleUrl = AppComponent\n ? \"/\" + path.relative(viteRoot, path.join(pagesDir, \"_app\"))\n : null;\n\n // Hydration entry: inline script that imports the page and hydrates.\n // Stores the React root and page loader for client-side navigation.\n const hydrationScript = `\n<script type=\"module\">\nimport React from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\nimport { wrapWithRouterContext } from \"next/router\";\n\nconst nextData = window.__NEXT_DATA__;\nconst { pageProps } = nextData.props;\n\nasync function hydrate() {\n const pageModule = await import(\"${pageModuleUrl}\");\n const PageComponent = pageModule.default;\n let element;\n ${\n appModuleUrl\n ? `\n const appModule = await import(\"${appModuleUrl}\");\n const AppComponent = appModule.default;\n window.__VINEXT_APP__ = AppComponent;\n element = React.createElement(AppComponent, { Component: PageComponent, pageProps });\n `\n : `\n element = React.createElement(PageComponent, pageProps);\n `\n }\n element = wrapWithRouterContext(element);\n const root = hydrateRoot(document.getElementById(\"__next\"), element);\n window.__VINEXT_ROOT__ = root;\n}\nhydrate();\n</script>`;\n\n const nextDataScript = `<script>window.__NEXT_DATA__ = ${safeJsonStringify({\n props: { pageProps },\n page: patternToNextFormat(route.pattern),\n query: params,\n isFallback: false,\n locale: locale ?? i18nConfig?.defaultLocale,\n locales: i18nConfig?.locales,\n defaultLocale: i18nConfig?.defaultLocale,\n // Include module URLs so client navigation can import pages directly\n __vinext: {\n pageModuleUrl,\n appModuleUrl,\n },\n })}${i18nConfig ? `;window.__VINEXT_LOCALE__=${safeJsonStringify(locale ?? i18nConfig.defaultLocale)};window.__VINEXT_LOCALES__=${safeJsonStringify(i18nConfig.locales)};window.__VINEXT_DEFAULT_LOCALE__=${safeJsonStringify(i18nConfig.defaultLocale)}` : \"\"}</script>`;\n\n // Try to load custom _document.tsx\n const docPath = path.join(pagesDir, \"_document\");\n let DocumentComponent: any = null;\n if (findFileWithExtensions(docPath)) {\n try {\n const docModule = await server.ssrLoadModule(docPath);\n DocumentComponent = docModule.default ?? null;\n } catch {\n // _document exists but failed to load\n }\n }\n\n const allScripts = `${nextDataScript}\\n ${hydrationScript}`;\n\n // Build cache headers for ISR responses\n const extraHeaders: Record<string, string> = {};\n if (isrRevalidateSeconds) {\n extraHeaders[\"Cache-Control\"] = `s-maxage=${isrRevalidateSeconds}, stale-while-revalidate`;\n extraHeaders[\"X-Vinext-Cache\"] = \"MISS\";\n }\n\n // Set HTTP Link header for font preloading.\n // This lets the browser (and CDN) start fetching font files before parsing HTML.\n if (allFontPreloads.length > 0) {\n extraHeaders[\"Link\"] = allFontPreloads\n .map((p) => `<${p.href}>; rel=preload; as=font; type=${p.type}; crossorigin`)\n .join(\", \");\n }\n\n // Stream the page using progressive SSR.\n // The shell (layouts, non-suspended content) arrives immediately.\n // Suspense content streams in as it resolves.\n await streamPageToResponse(res, element, {\n url,\n server,\n fontHeadHTML,\n scripts: allScripts,\n DocumentComponent,\n statusCode,\n extraHeaders,\n // Collect head HTML AFTER the shell renders (inside streamPageToResponse,\n // after renderToReadableStream resolves). Head tags from Suspense\n // children arrive late — this matches Next.js behavior.\n getHeadHTML: () => typeof headShim.getSSRHeadHTML === \"function\"\n ? headShim.getSSRHeadHTML()\n : \"\",\n });\n\n // Clear SSR context after rendering\n if (typeof routerShim.setSSRContext === \"function\") {\n routerShim.setSSRContext(null);\n }\n\n // If ISR is enabled, we need the full HTML for caching.\n // For ISR, re-render synchronously to get the complete HTML string.\n // This runs after the stream is already sent, so it doesn't affect TTFB.\n if (isrRevalidateSeconds !== null && isrRevalidateSeconds > 0) {\n let isrElement = AppComponent\n ? createElement(AppComponent, { Component: pageModule.default, pageProps })\n : createElement(pageModule.default, pageProps);\n if (wrapWithRouterContext) {\n isrElement = wrapWithRouterContext(isrElement);\n }\n const isrBodyHtml = await renderToStringAsync(isrElement);\n const isrHtml = `<!DOCTYPE html><html><head></head><body><div id=\"__next\">${isrBodyHtml}</div>${allScripts}</body></html>`;\n const cacheKey = isrCacheKey(\"pages\", url.split(\"?\")[0]);\n await isrSet(\n cacheKey,\n buildPagesCacheValue(isrHtml, pageProps),\n isrRevalidateSeconds,\n );\n setRevalidateDuration(cacheKey, isrRevalidateSeconds);\n }\n } catch (e) {\n // Let Vite fix the stack trace for better dev experience\n server.ssrFixStacktrace(e as Error);\n console.error(e);\n // Report error via instrumentation hook if registered\n reportRequestError(\n e instanceof Error ? e : new Error(String(e)),\n {\n path: url,\n method: req.method ?? \"GET\",\n headers: Object.fromEntries(\n Object.entries(req.headers).map(([k, v]) => [k, Array.isArray(v) ? v.join(\", \") : String(v ?? \"\")]),\n ),\n },\n { routerKind: \"Pages Router\", routePath: route.pattern, routeType: \"render\" },\n ).catch(() => { /* ignore reporting errors */ });\n // Try to render custom 500 error page\n try {\n await renderErrorPage(server, req, res, url, pagesDir, 500);\n } catch (fallbackErr) {\n // If error page itself fails, fall back to plain text.\n // This is a dev-only code path (prod uses prod-server.ts), so\n // include the error message for debugging.\n res.statusCode = 500;\n res.end(`Internal Server Error: ${(fallbackErr as Error).message}`);\n }\n } finally {\n // Cleanup is handled by ALS scope unwinding —\n // each runWith*() scope is automatically cleaned up when it exits.\n }\n }) // end runWithFetchCache\n ) // end runWithPrivateCache\n ) // end _runWithCacheState\n ) // end runWithHeadState\n ); // end runWithRouterState\n };\n}\n\n/**\n * Render a custom error page (404.tsx, 500.tsx, or _error.tsx).\n *\n * Next.js resolution order:\n * - 404: pages/404.tsx -> pages/_error.tsx -> default\n * - 500: pages/500.tsx -> pages/_error.tsx -> default\n * - other: pages/_error.tsx -> default\n */\nasync function renderErrorPage(\n server: ViteDevServer,\n _req: IncomingMessage,\n res: ServerResponse,\n url: string,\n pagesDir: string,\n statusCode: number,\n wrapWithRouterContext?: ((el: React.ReactElement) => React.ReactElement) | null,\n): Promise<void> {\n // Try specific status page first, then _error, then fallback\n const candidates =\n statusCode === 404\n ? [\"404\", \"_error\"]\n : statusCode === 500\n ? [\"500\", \"_error\"]\n : [\"_error\"];\n\n for (const candidate of candidates) {\n try {\n const candidatePath = path.join(pagesDir, candidate);\n if (!findFileWithExtensions(candidatePath)) continue;\n\n const errorModule = await server.ssrLoadModule(candidatePath);\n const ErrorComponent = errorModule.default;\n if (!ErrorComponent) continue;\n\n // Try to load _app.tsx to wrap the error page\n let AppComponent: any = null;\n const appPathErr = path.join(pagesDir, \"_app\");\n if (findFileWithExtensions(appPathErr)) {\n try {\n const appModule = await server.ssrLoadModule(appPathErr);\n AppComponent = appModule.default ?? null;\n } catch {\n // _app exists but failed to load\n }\n }\n\n const createElement = React.createElement;\n const errorProps = { statusCode };\n\n // If the caller didn't supply wrapWithRouterContext, load it now.\n // ssrLoadModule caches internally so the cost is negligible.\n let wrapFn = wrapWithRouterContext;\n if (!wrapFn) {\n try {\n const errRouterShim = await server.ssrLoadModule(\"next/router\");\n wrapFn = errRouterShim.wrapWithRouterContext;\n } catch {\n // router shim not available — continue without it\n }\n }\n\n let element: React.ReactElement;\n if (AppComponent) {\n element = createElement(AppComponent, {\n Component: ErrorComponent,\n pageProps: errorProps,\n });\n } else {\n element = createElement(ErrorComponent, errorProps);\n }\n\n if (wrapFn) {\n element = wrapFn(element);\n }\n\n const bodyHtml = await renderToStringAsync(element);\n\n // Try custom _document\n let html: string;\n let DocumentComponent: any = null;\n const docPathErr = path.join(pagesDir, \"_document\");\n if (findFileWithExtensions(docPathErr)) {\n try {\n const docModule = await server.ssrLoadModule(docPathErr);\n DocumentComponent = docModule.default ?? null;\n } catch {\n // _document exists but failed to load\n }\n }\n\n if (DocumentComponent) {\n const docElement = createElement(DocumentComponent);\n let docHtml = await renderToStringAsync(docElement);\n docHtml = docHtml.replace(\"__NEXT_MAIN__\", bodyHtml);\n docHtml = docHtml.replace(\"<!-- __NEXT_SCRIPTS__ -->\", \"\");\n html = docHtml;\n } else {\n html = `<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n</head>\n<body>\n <div id=\"__next\">${bodyHtml}</div>\n</body>\n</html>`;\n }\n\n const transformedHtml = await server.transformIndexHtml(url, html);\n res.writeHead(statusCode, { \"Content-Type\": \"text/html\" });\n res.end(transformedHtml);\n return;\n } catch {\n // This candidate doesn't exist, try next\n continue;\n }\n }\n\n // No custom error page found — use plain text fallback\n res.writeHead(statusCode, { \"Content-Type\": \"text/plain\" });\n res.end(`${statusCode} - ${statusCode === 404 ? \"Page not found\" : \"Internal Server Error\"}`);\n}\n\n\n"]}
|
|
1
|
+
{"version":3,"file":"dev-server.js","sourceRoot":"","sources":["../../src/server/dev-server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAE7E,OAAO,EACL,MAAM,EACN,MAAM,EACN,WAAW,EACX,oBAAoB,EACpB,6BAA6B,EAC7B,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,qEAAqE;AACrE,8DAA8D;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,gBAAgB,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,E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E,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC,CAAC;YAC3D,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;YACzB,OAAO;QACT,CAAC;QAAC,MAAM,CAAC;YACP,yCAAyC;YACzC,SAAS;QACX,CAAC;IACH,CAAC;IAED,uDAAuD;IACvD,GAAG,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,CAAC;IAC5D,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,MAAM,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,uBAAuB,EAAE,CAAC,CAAC;AAChG,CAAC","sourcesContent":["import type { ViteDevServer } from \"vite\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport type { Route } from \"../routing/pages-router.js\";\nimport { matchRoute, patternToNextFormat } from \"../routing/pages-router.js\";\nimport type { NextI18nConfig } from \"../config/next-config.js\";\nimport {\n isrGet,\n isrSet,\n isrCacheKey,\n buildPagesCacheValue,\n triggerBackgroundRegeneration,\n setRevalidateDuration,\n getRevalidateDuration,\n} from \"./isr-cache.js\";\nimport type { CachedPagesValue } from \"../shims/cache.js\";\nimport { runWithFetchCache } from \"../shims/fetch-cache.js\";\nimport { _runWithCacheState } from \"../shims/cache.js\";\nimport { runWithPrivateCache } from \"../shims/cache-runtime.js\";\n// Import server-only state modules to register ALS-backed accessors.\n// These modules must be imported before any rendering occurs.\nimport { runWithRouterState } from \"../shims/router-state.js\";\nimport { runWithHeadState } from \"../shims/head-state.js\";\nimport { reportRequestError } from \"./instrumentation.js\";\nimport { safeJsonStringify } from \"./html.js\";\nimport { parseQueryString as parseQuery } from \"../utils/query.js\";\nimport path from \"node:path\";\nimport fs from \"node:fs\";\nimport React from \"react\";\nimport { renderToReadableStream } from \"react-dom/server.edge\";\nimport { logRequest, now } from \"./request-log.js\";\n\nconst PAGE_EXTENSIONS = [\".tsx\", \".ts\", \".jsx\", \".js\"];\n\n/**\n * Render a React element to a string using renderToReadableStream.\n *\n * Uses the edge-compatible Web Streams API. Waits for all Suspense\n * boundaries to resolve via stream.allReady before collecting output.\n * Used for _document rendering and error pages (small, non-streaming).\n */\nasync function renderToStringAsync(element: React.ReactElement): Promise<string> {\n const stream = await renderToReadableStream(element);\n await stream.allReady;\n return new Response(stream).text();\n}\n\n/** Body placeholder used to split the document shell for streaming. */\nconst STREAM_BODY_MARKER = \"<!--VINEXT_STREAM_BODY-->\";\n\n/**\n * Stream a Pages Router page response using progressive SSR.\n *\n * Sends the HTML shell (head, layout, Suspense fallbacks) immediately\n * when the React shell is ready, then streams Suspense content as it\n * resolves. This gives the browser content to render while slow data\n * loads are still in flight.\n *\n * `__NEXT_DATA__` and the hydration script are appended after the body\n * stream completes (the data is known before rendering starts, but\n * deferring them reduces TTFB and lets the browser start parsing the\n * shell sooner).\n */\nasync function streamPageToResponse(\n res: ServerResponse,\n element: React.ReactElement,\n options: {\n url: string;\n server: ViteDevServer;\n fontHeadHTML: string;\n scripts: string;\n DocumentComponent: React.ComponentType | null;\n statusCode?: number;\n extraHeaders?: Record<string, string | string[]>;\n /** Called after renderToReadableStream resolves (shell ready) to collect head HTML */\n getHeadHTML: () => string;\n },\n): Promise<void> {\n const {\n url,\n server,\n fontHeadHTML,\n scripts,\n DocumentComponent,\n statusCode = 200,\n extraHeaders,\n getHeadHTML,\n } = options;\n\n // Start the React body stream FIRST — the promise resolves when the\n // shell is ready (synchronous content outside Suspense boundaries).\n // This triggers the render which populates <Head> tags.\n const bodyStream = await renderToReadableStream(element);\n\n // Now that the shell has rendered, collect head HTML\n const headHTML = getHeadHTML();\n\n // Build the document shell with a placeholder for the body\n let shellTemplate: string;\n\n if (DocumentComponent) {\n const docElement = React.createElement(DocumentComponent);\n let docHtml = await renderToStringAsync(docElement);\n // Replace __NEXT_MAIN__ with our stream marker\n docHtml = docHtml.replace(\"__NEXT_MAIN__\", STREAM_BODY_MARKER);\n // Inject head tags\n if (headHTML || fontHeadHTML) {\n docHtml = docHtml.replace(\"</head>\", ` ${fontHeadHTML}${headHTML}\\n</head>`);\n }\n // Inject scripts: replace placeholder or append before </body>\n docHtml = docHtml.replace(\"<!-- __NEXT_SCRIPTS__ -->\", scripts);\n if (!docHtml.includes(\"__NEXT_DATA__\")) {\n docHtml = docHtml.replace(\"</body>\", ` ${scripts}\\n</body>`);\n }\n shellTemplate = docHtml;\n } else {\n shellTemplate = `<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n ${fontHeadHTML}${headHTML}\n</head>\n<body>\n <div id=\"__next\">${STREAM_BODY_MARKER}</div>\n ${scripts}\n</body>\n</html>`;\n }\n\n // Apply Vite's HTML transforms (injects HMR client, etc.) on the full\n // shell template, then split at the body marker.\n const transformedShell = await server.transformIndexHtml(url, shellTemplate);\n const markerIdx = transformedShell.indexOf(STREAM_BODY_MARKER);\n const prefix = transformedShell.slice(0, markerIdx);\n const suffix = transformedShell.slice(markerIdx + STREAM_BODY_MARKER.length);\n\n // Send headers and start streaming.\n // Set array-valued headers (e.g. Set-Cookie from gSSP) via setHeader()\n // before writeHead(), since writeHead()'s headers object doesn't handle\n // arrays portably. Then writeHead() merges with any setHeader() calls.\n const headers: Record<string, string> = {\n \"Content-Type\": \"text/html\",\n \"Transfer-Encoding\": \"chunked\",\n };\n if (extraHeaders) {\n for (const [key, val] of Object.entries(extraHeaders)) {\n if (Array.isArray(val)) {\n res.setHeader(key, val);\n } else {\n headers[key] = val;\n }\n }\n }\n res.writeHead(statusCode, headers);\n\n // Write the document prefix (head, opening body)\n res.write(prefix);\n\n // Pipe the React body stream through (Suspense content streams progressively)\n const reader = bodyStream.getReader();\n try {\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n res.write(value);\n }\n } finally {\n reader.releaseLock();\n }\n\n // Write the document suffix (closing tags, scripts)\n res.end(suffix);\n}\n\n/** Check if a file exists with any page extension (tsx, ts, jsx, js). */\nfunction findFileWithExtensions(basePath: string): boolean {\n return PAGE_EXTENSIONS.some((ext) => fs.existsSync(basePath + ext));\n}\n\n/**\n * Extract locale prefix from a URL path.\n * e.g. /fr/about -> { locale: \"fr\", url: \"/about\", hadPrefix: true }\n * /about -> { locale: \"en\", url: \"/about\", hadPrefix: false } (defaultLocale)\n */\nexport function extractLocaleFromUrl(\n url: string,\n i18nConfig: NextI18nConfig,\n): { locale: string; url: string; hadPrefix: boolean } {\n const pathname = url.split(\"?\")[0];\n const parts = pathname.split(\"/\").filter(Boolean);\n const query = url.includes(\"?\") ? url.slice(url.indexOf(\"?\")) : \"\";\n\n if (parts.length > 0 && i18nConfig.locales.includes(parts[0])) {\n const locale = parts[0];\n const rest = \"/\" + parts.slice(1).join(\"/\");\n return { locale, url: (rest || \"/\") + query, hadPrefix: true };\n }\n\n return { locale: i18nConfig.defaultLocale, url, hadPrefix: false };\n}\n\n/**\n * Detect the preferred locale from the Accept-Language header.\n * Returns the best matching locale or null.\n */\nexport function detectLocaleFromHeaders(\n req: IncomingMessage,\n i18nConfig: NextI18nConfig,\n): string | null {\n const acceptLang = req.headers[\"accept-language\"];\n if (!acceptLang) return null;\n\n // Parse Accept-Language: en-US,en;q=0.9,fr;q=0.8\n const langs = acceptLang\n .split(\",\")\n .map((part) => {\n const [lang, qPart] = part.trim().split(\";\");\n const q = qPart ? parseFloat(qPart.replace(\"q=\", \"\")) : 1;\n return { lang: lang.trim().toLowerCase(), q };\n })\n .sort((a, b) => b.q - a.q);\n\n for (const { lang } of langs) {\n // Exact match\n const exactMatch = i18nConfig.locales.find((l) => l.toLowerCase() === lang);\n if (exactMatch) return exactMatch;\n\n // Prefix match (e.g. \"en-US\" matches \"en\")\n const prefix = lang.split(\"-\")[0];\n const prefixMatch = i18nConfig.locales.find(\n (l) => l.toLowerCase() === prefix || l.toLowerCase().startsWith(prefix + \"-\"),\n );\n if (prefixMatch) return prefixMatch;\n }\n\n return null;\n}\n\n/**\n * Parse the NEXT_LOCALE cookie from a request.\n * Returns the cookie value if it matches a configured locale, otherwise null.\n */\nexport function parseCookieLocale(\n req: IncomingMessage,\n i18nConfig: NextI18nConfig,\n): string | null {\n const cookieHeader = req.headers.cookie;\n if (!cookieHeader) return null;\n\n // Simple cookie parsing — find NEXT_LOCALE=value\n const match = cookieHeader.match(/(?:^|;\\s*)NEXT_LOCALE=([^;]*)/);\n if (!match) return null;\n\n let value: string;\n try {\n value = decodeURIComponent(match[1].trim());\n } catch {\n return null;\n }\n // Only return if it's a valid configured locale\n if (i18nConfig.locales.includes(value)) return value;\n return null;\n}\n\n/**\n * Create an SSR request handler for the Pages Router.\n *\n * For each request:\n * 1. Match the URL against discovered routes\n * 2. Load the page module via Vite's SSR module loader\n * 3. Call getServerSideProps/getStaticProps if present\n * 4. Render the component to HTML\n * 5. Wrap in _document shell and send response\n */\nexport function createSSRHandler(\n server: ViteDevServer,\n routes: Route[],\n pagesDir: string,\n i18nConfig?: NextI18nConfig | null,\n) {\n return async (\n req: IncomingMessage,\n res: ServerResponse,\n url: string,\n /** Status code override — propagated from middleware rewrite status. */\n statusCode?: number,\n ): Promise<void> => {\n const _reqStart = now();\n let _compileEnd: number | undefined;\n let _renderEnd: number | undefined;\n\n res.on(\"finish\", () => {\n const totalMs = now() - _reqStart;\n const compileMs = _compileEnd !== undefined ? Math.round(_compileEnd - _reqStart) : undefined;\n // renderMs = time from end of compile to end of stream.\n // _renderEnd is set just after streamPageToResponse resolves.\n const renderMs = _renderEnd !== undefined && _compileEnd !== undefined\n ? Math.round(_renderEnd - _compileEnd)\n : undefined;\n logRequest({\n method: req.method ?? \"GET\",\n url,\n status: res.statusCode,\n totalMs,\n compileMs,\n renderMs,\n });\n });\n\n // --- i18n: extract locale from URL prefix ---\n let locale: string | undefined;\n let localeStrippedUrl = url;\n\n if (i18nConfig) {\n const parsed = extractLocaleFromUrl(url, i18nConfig);\n locale = parsed.locale;\n localeStrippedUrl = parsed.url;\n\n // If no locale prefix, check NEXT_LOCALE cookie first, then Accept-Language\n if (!parsed.hadPrefix) {\n const cookieLocale = parseCookieLocale(req, i18nConfig);\n if (cookieLocale && cookieLocale !== i18nConfig.defaultLocale) {\n // NEXT_LOCALE cookie overrides Accept-Language — redirect to cookie locale\n const redirectUrl = `/${cookieLocale}${url === \"/\" ? \"\" : url}`;\n res.writeHead(307, { Location: redirectUrl });\n res.end();\n return;\n }\n // If no cookie or cookie matches default, fall through to Accept-Language detection\n if (!cookieLocale && i18nConfig.localeDetection !== false) {\n const detectedLocale = detectLocaleFromHeaders(req, i18nConfig);\n if (detectedLocale && detectedLocale !== i18nConfig.defaultLocale) {\n const redirectUrl = `/${detectedLocale}${url === \"/\" ? \"\" : url}`;\n res.writeHead(307, { Location: redirectUrl });\n res.end();\n return;\n }\n }\n }\n }\n\n const match = matchRoute(localeStrippedUrl, routes);\n\n if (!match) {\n // No route matched — try to render custom 404 page\n await renderErrorPage(server, req, res, url, pagesDir, 404);\n return;\n }\n\n const { route, params } = match;\n\n // Wrap the entire request in nested AsyncLocalStorage.run() scopes to\n // ensure per-request isolation for all state modules.\n return runWithRouterState(() =>\n runWithHeadState(() =>\n _runWithCacheState(() =>\n runWithPrivateCache(() =>\n runWithFetchCache(async () => {\n try {\n // Set SSR context for the router shim so useRouter() returns\n // the correct URL and params during server-side rendering.\n const routerShim = await server.ssrLoadModule(\"next/router\");\n if (typeof routerShim.setSSRContext === \"function\") {\n routerShim.setSSRContext({\n pathname: localeStrippedUrl.split(\"?\")[0],\n query: { ...params, ...parseQuery(url) },\n asPath: url,\n locale: locale ?? i18nConfig?.defaultLocale,\n locales: i18nConfig?.locales,\n defaultLocale: i18nConfig?.defaultLocale,\n });\n }\n\n // Set globalThis locale info for Link component locale prop support during SSR\n if (i18nConfig) {\n (globalThis as any).__VINEXT_LOCALE__ = locale ?? i18nConfig.defaultLocale;\n (globalThis as any).__VINEXT_LOCALES__ = i18nConfig.locales;\n (globalThis as any).__VINEXT_DEFAULT_LOCALE__ = i18nConfig.defaultLocale;\n }\n\n // Load the page module through Vite's SSR pipeline\n // This gives us HMR and transform support for free\n const pageModule = await server.ssrLoadModule(route.filePath);\n // Mark end of compile phase: everything from here is rendering.\n _compileEnd = now();\n\n // Get the page component (default export)\n const PageComponent = pageModule.default;\n if (!PageComponent) {\n console.error(`[vinext] Page ${route.filePath} has no default export`);\n res.statusCode = 500;\n res.end(\"Page has no default export\");\n return;\n }\n\n // Collect page props via data fetching methods\n let pageProps: Record<string, unknown> = {};\n let isrRevalidateSeconds: number | null = null;\n\n // Handle getStaticPaths for dynamic routes: validate the path\n // and respect fallback: false (return 404 for unlisted paths).\n if (typeof pageModule.getStaticPaths === \"function\" && route.isDynamic) {\n const pathsResult = await pageModule.getStaticPaths({\n locales: i18nConfig?.locales ?? [],\n defaultLocale: i18nConfig?.defaultLocale ?? \"\",\n });\n const fallback = pathsResult?.fallback ?? false;\n\n if (fallback === false) {\n // Only allow paths explicitly listed in getStaticPaths\n const paths: Array<{ params: Record<string, string | string[]> }> =\n pathsResult?.paths ?? [];\n const isValidPath = paths.some((p: { params: Record<string, string | string[]> }) => {\n return Object.entries(p.params).every(([key, val]) => {\n const actual = params[key];\n if (Array.isArray(val)) {\n return Array.isArray(actual) && val.join(\"/\") === actual.join(\"/\");\n }\n return String(val) === String(actual);\n });\n });\n\n if (!isValidPath) {\n await renderErrorPage(server, req, res, url, pagesDir, 404, routerShim.wrapWithRouterContext);\n return;\n }\n }\n // fallback: true or \"blocking\" — always SSR on-demand.\n // In dev mode, Next.js does the same (no fallback shell).\n // In production, both modes SSR on-demand with caching.\n // The difference is that fallback:true could serve a shell first,\n // but since we always have data available via SSR, we render fully.\n }\n\n // Headers set by getServerSideProps for explicit forwarding to\n // streamPageToResponse. Without this, they survive only through\n // Node.js writeHead() implicitly merging setHeader() calls, which\n // would silently break if streamPageToResponse is refactored.\n const gsspExtraHeaders: Record<string, string | string[]> = {};\n\n if (typeof pageModule.getServerSideProps === \"function\") {\n // Snapshot existing headers so we can detect what gSSP adds.\n const headersBeforeGSSP = new Set(Object.keys(res.getHeaders()));\n\n const context = {\n params,\n req,\n res,\n query: parseQuery(url),\n resolvedUrl: localeStrippedUrl,\n locale: locale ?? i18nConfig?.defaultLocale,\n locales: i18nConfig?.locales,\n defaultLocale: i18nConfig?.defaultLocale,\n };\n const result = await pageModule.getServerSideProps(context);\n // If gSSP called res.end() directly (short-circuit pattern),\n // the response is already sent. Do not continue rendering.\n // Note: middleware headers are already on `res` (middleware runs\n // before this handler in the connect chain), so they are included\n // in the short-circuited response. The prod path achieves the same\n // result via the worker entry merging middleware headers after\n // renderPage() returns.\n if (res.writableEnded) {\n return;\n }\n if (result && \"props\" in result) {\n pageProps = result.props;\n }\n if (result && \"redirect\" in result) {\n const { redirect } = result;\n const status = redirect.statusCode ?? (redirect.permanent ? 308 : 307);\n // Sanitize destination to prevent open redirect via protocol-relative URLs.\n // Also normalize backslashes — browsers treat \\ as / in URL contexts.\n let dest = redirect.destination;\n if (!dest.startsWith(\"http://\") && !dest.startsWith(\"https://\")) {\n dest = dest.replace(/^[\\\\/]+/, \"/\");\n }\n res.writeHead(status, {\n Location: dest,\n });\n res.end();\n return;\n }\n if (result && \"notFound\" in result && result.notFound) {\n await renderErrorPage(server, req, res, url, pagesDir, 404, routerShim.wrapWithRouterContext);\n return;\n }\n // Preserve any status code set by gSSP (e.g. res.statusCode = 201).\n // This takes precedence over the default 200 but not over middleware status.\n if (!statusCode && res.statusCode !== 200) {\n statusCode = res.statusCode;\n }\n\n // Capture headers newly set by gSSP and forward them explicitly.\n // Remove from `res` to prevent duplication when writeHead() merges.\n const headersAfterGSSP = res.getHeaders();\n for (const [key, val] of Object.entries(headersAfterGSSP)) {\n if (headersBeforeGSSP.has(key) || val == null) continue;\n res.removeHeader(key);\n if (Array.isArray(val)) {\n gsspExtraHeaders[key] = val.map(String);\n } else {\n gsspExtraHeaders[key] = String(val);\n }\n }\n }\n // Collect font preloads early so ISR cached responses can include\n // the Link header (font preloads are module-level state that persists\n // across requests after the font modules are first loaded).\n let earlyFontLinkHeader = \"\";\n try {\n const earlyPreloads: Array<{ href: string; type: string }> = [];\n const fontGoogleEarly = await server.ssrLoadModule(\"next/font/google\");\n if (typeof fontGoogleEarly.getSSRFontPreloads === \"function\") {\n earlyPreloads.push(...fontGoogleEarly.getSSRFontPreloads());\n }\n const fontLocalEarly = await server.ssrLoadModule(\"next/font/local\");\n if (typeof fontLocalEarly.getSSRFontPreloads === \"function\") {\n earlyPreloads.push(...fontLocalEarly.getSSRFontPreloads());\n }\n if (earlyPreloads.length > 0) {\n earlyFontLinkHeader = earlyPreloads\n .map((p) => `<${p.href}>; rel=preload; as=font; type=${p.type}; crossorigin`)\n .join(\", \");\n }\n } catch {\n // Font modules not loaded yet — skip\n }\n\n if (typeof pageModule.getStaticProps === \"function\") {\n // Check ISR cache before calling getStaticProps\n const cacheKey = isrCacheKey(\"pages\", url.split(\"?\")[0]);\n const cached = await isrGet(cacheKey);\n\n if (cached && !cached.isStale && cached.value.value?.kind === \"PAGES\") {\n // Fresh cache hit — serve directly\n const cachedPage = cached.value.value as CachedPagesValue;\n const cachedHtml = cachedPage.html;\n const transformedHtml = await server.transformIndexHtml(url, cachedHtml);\n const revalidateSecs = getRevalidateDuration(cacheKey) ?? 60;\n const hitHeaders: Record<string, string> = {\n \"Content-Type\": \"text/html\",\n \"X-Vinext-Cache\": \"HIT\",\n \"Cache-Control\": `s-maxage=${revalidateSecs}, stale-while-revalidate`,\n };\n if (earlyFontLinkHeader) hitHeaders[\"Link\"] = earlyFontLinkHeader;\n res.writeHead(200, hitHeaders);\n res.end(transformedHtml);\n return;\n }\n\n if (cached && cached.isStale && cached.value.value?.kind === \"PAGES\") {\n // Stale hit — serve stale immediately, trigger background regen\n const cachedPage = cached.value.value as CachedPagesValue;\n const cachedHtml = cachedPage.html;\n const transformedHtml = await server.transformIndexHtml(url, cachedHtml);\n\n // Trigger background regeneration: re-run getStaticProps and\n // update the cache so the next request is a HIT with fresh data.\n triggerBackgroundRegeneration(cacheKey, async () => {\n const freshResult = await pageModule.getStaticProps({ params });\n if (freshResult && \"props\" in freshResult) {\n const revalidate = typeof freshResult.revalidate === \"number\" ? freshResult.revalidate : 0;\n if (revalidate > 0) {\n await isrSet(cacheKey, buildPagesCacheValue(cachedHtml, freshResult.props), revalidate);\n }\n }\n });\n\n const revalidateSecs = getRevalidateDuration(cacheKey) ?? 60;\n const staleHeaders: Record<string, string> = {\n \"Content-Type\": \"text/html\",\n \"X-Vinext-Cache\": \"STALE\",\n \"Cache-Control\": `s-maxage=${revalidateSecs}, stale-while-revalidate`,\n };\n if (earlyFontLinkHeader) staleHeaders[\"Link\"] = earlyFontLinkHeader;\n res.writeHead(200, staleHeaders);\n res.end(transformedHtml);\n return;\n }\n\n // Cache miss — call getStaticProps normally\n const context = {\n params,\n locale: locale ?? i18nConfig?.defaultLocale,\n locales: i18nConfig?.locales,\n defaultLocale: i18nConfig?.defaultLocale,\n };\n const result = await pageModule.getStaticProps(context);\n if (result && \"props\" in result) {\n pageProps = result.props;\n }\n if (result && \"redirect\" in result) {\n const { redirect } = result;\n const status = redirect.statusCode ?? (redirect.permanent ? 308 : 307);\n // Sanitize destination to prevent open redirect via protocol-relative URLs.\n // Also normalize backslashes — browsers treat \\ as / in URL contexts.\n let dest = redirect.destination;\n if (!dest.startsWith(\"http://\") && !dest.startsWith(\"https://\")) {\n dest = dest.replace(/^[\\\\/]+/, \"/\");\n }\n res.writeHead(status, {\n Location: dest,\n });\n res.end();\n return;\n }\n if (result && \"notFound\" in result && result.notFound) {\n await renderErrorPage(server, req, res, url, pagesDir, 404, routerShim.wrapWithRouterContext);\n return;\n }\n\n // Extract revalidate period for ISR caching after render\n if (typeof result?.revalidate === \"number\" && result.revalidate > 0) {\n isrRevalidateSeconds = result.revalidate;\n }\n }\n\n // Try to load _app.tsx if it exists\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let AppComponent: any = null;\n const appPath = path.join(pagesDir, \"_app\");\n if (findFileWithExtensions(appPath)) {\n try {\n const appModule = await server.ssrLoadModule(appPath);\n AppComponent = appModule.default ?? null;\n } catch {\n // _app exists but failed to load\n }\n }\n\n // React and ReactDOMServer are imported at the top level as native Node\n // modules. They must NOT go through Vite's SSR module runner because\n // React is CJS and the ESModulesEvaluator doesn't define `module`.\n const createElement = React.createElement;\n let element: React.ReactElement;\n\n // wrapWithRouterContext wraps the element in RouterContext.Provider so that\n // next/compat/router's useRouter() returns the real router.\n const wrapWithRouterContext = routerShim.wrapWithRouterContext;\n\n if (AppComponent) {\n element = createElement(AppComponent, {\n Component: PageComponent,\n pageProps,\n });\n } else {\n element = createElement(PageComponent, pageProps);\n }\n\n if (wrapWithRouterContext) {\n element = wrapWithRouterContext(element);\n }\n\n // Reset SSR head collector before rendering so <Head> tags are captured\n const headShim = await server.ssrLoadModule(\"next/head\");\n if (typeof headShim.resetSSRHead === \"function\") {\n headShim.resetSSRHead();\n }\n\n // Flush any pending dynamic() preloads so components are ready\n const dynamicShim = await server.ssrLoadModule(\"next/dynamic\");\n if (typeof dynamicShim.flushPreloads === \"function\") {\n await dynamicShim.flushPreloads();\n }\n\n // Collect any <Head> tags that were rendered during data fetching\n // (shell head tags — Suspense children's head tags arrive late,\n // matching Next.js behavior)\n\n // Collect SSR font links (Google Fonts <link> tags) and font class styles\n let fontHeadHTML = \"\";\n const allFontStyles: string[] = [];\n const allFontPreloads: Array<{ href: string; type: string }> = [];\n try {\n const fontGoogle = await server.ssrLoadModule(\"next/font/google\");\n if (typeof fontGoogle.getSSRFontLinks === \"function\") {\n const fontUrls = fontGoogle.getSSRFontLinks();\n for (const fontUrl of fontUrls) {\n const safeFontUrl = fontUrl.replace(/&/g, \"&\").replace(/\"/g, \""\");\n fontHeadHTML += `<link rel=\"stylesheet\" href=\"${safeFontUrl}\" />\\n `;\n }\n }\n if (typeof fontGoogle.getSSRFontStyles === \"function\") {\n allFontStyles.push(...fontGoogle.getSSRFontStyles());\n }\n // Collect preloads from self-hosted Google fonts\n if (typeof fontGoogle.getSSRFontPreloads === \"function\") {\n allFontPreloads.push(...fontGoogle.getSSRFontPreloads());\n }\n } catch {\n // next/font/google not used — skip\n }\n try {\n const fontLocal = await server.ssrLoadModule(\"next/font/local\");\n if (typeof fontLocal.getSSRFontStyles === \"function\") {\n allFontStyles.push(...fontLocal.getSSRFontStyles());\n }\n // Collect preloads from local font files\n if (typeof fontLocal.getSSRFontPreloads === \"function\") {\n allFontPreloads.push(...fontLocal.getSSRFontPreloads());\n }\n } catch {\n // next/font/local not used — skip\n }\n // Emit <link rel=\"preload\"> for all collected font files (Google + local)\n for (const { href, type } of allFontPreloads) {\n // Escape href/type to prevent HTML attribute injection (defense-in-depth;\n // Vite-resolved asset paths should never contain special chars).\n const safeHref = href.replace(/&/g, \"&\").replace(/\"/g, \""\");\n const safeType = type.replace(/&/g, \"&\").replace(/\"/g, \""\");\n fontHeadHTML += `<link rel=\"preload\" href=\"${safeHref}\" as=\"font\" type=\"${safeType}\" crossorigin />\\n `;\n }\n if (allFontStyles.length > 0) {\n fontHeadHTML += `<style data-vinext-fonts>${allFontStyles.join(\"\\n\")}</style>\\n `;\n }\n\n // Convert absolute file paths to Vite-servable URLs (relative to root)\n const viteRoot = server.config.root;\n const pageModuleUrl = \"/\" + path.relative(viteRoot, route.filePath);\n const appModuleUrl = AppComponent\n ? \"/\" + path.relative(viteRoot, path.join(pagesDir, \"_app\"))\n : null;\n\n // Hydration entry: inline script that imports the page and hydrates.\n // Stores the React root and page loader for client-side navigation.\n const hydrationScript = `\n<script type=\"module\">\nimport React from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\nimport { wrapWithRouterContext } from \"next/router\";\n\nconst nextData = window.__NEXT_DATA__;\nconst { pageProps } = nextData.props;\n\nasync function hydrate() {\n const pageModule = await import(\"${pageModuleUrl}\");\n const PageComponent = pageModule.default;\n let element;\n ${\n appModuleUrl\n ? `\n const appModule = await import(\"${appModuleUrl}\");\n const AppComponent = appModule.default;\n window.__VINEXT_APP__ = AppComponent;\n element = React.createElement(AppComponent, { Component: PageComponent, pageProps });\n `\n : `\n element = React.createElement(PageComponent, pageProps);\n `\n }\n element = wrapWithRouterContext(element);\n const root = hydrateRoot(document.getElementById(\"__next\"), element);\n window.__VINEXT_ROOT__ = root;\n}\nhydrate();\n</script>`;\n\n const nextDataScript = `<script>window.__NEXT_DATA__ = ${safeJsonStringify({\n props: { pageProps },\n page: patternToNextFormat(route.pattern),\n query: params,\n isFallback: false,\n locale: locale ?? i18nConfig?.defaultLocale,\n locales: i18nConfig?.locales,\n defaultLocale: i18nConfig?.defaultLocale,\n // Include module URLs so client navigation can import pages directly\n __vinext: {\n pageModuleUrl,\n appModuleUrl,\n },\n })}${i18nConfig ? `;window.__VINEXT_LOCALE__=${safeJsonStringify(locale ?? i18nConfig.defaultLocale)};window.__VINEXT_LOCALES__=${safeJsonStringify(i18nConfig.locales)};window.__VINEXT_DEFAULT_LOCALE__=${safeJsonStringify(i18nConfig.defaultLocale)}` : \"\"}</script>`;\n\n // Try to load custom _document.tsx\n const docPath = path.join(pagesDir, \"_document\");\n let DocumentComponent: any = null;\n if (findFileWithExtensions(docPath)) {\n try {\n const docModule = await server.ssrLoadModule(docPath);\n DocumentComponent = docModule.default ?? null;\n } catch {\n // _document exists but failed to load\n }\n }\n\n const allScripts = `${nextDataScript}\\n ${hydrationScript}`;\n\n // Build response headers: start with gSSP headers, then layer on\n // ISR and font preload headers (which take precedence).\n const extraHeaders: Record<string, string | string[]> = { ...gsspExtraHeaders };\n if (isrRevalidateSeconds) {\n extraHeaders[\"Cache-Control\"] = `s-maxage=${isrRevalidateSeconds}, stale-while-revalidate`;\n extraHeaders[\"X-Vinext-Cache\"] = \"MISS\";\n }\n\n // Set HTTP Link header for font preloading.\n // This lets the browser (and CDN) start fetching font files before parsing HTML.\n if (allFontPreloads.length > 0) {\n extraHeaders[\"Link\"] = allFontPreloads\n .map((p) => `<${p.href}>; rel=preload; as=font; type=${p.type}; crossorigin`)\n .join(\", \");\n }\n\n // Stream the page using progressive SSR.\n // The shell (layouts, non-suspended content) arrives immediately.\n // Suspense content streams in as it resolves.\n await streamPageToResponse(res, element, {\n url,\n server,\n fontHeadHTML,\n scripts: allScripts,\n DocumentComponent,\n statusCode,\n extraHeaders,\n // Collect head HTML AFTER the shell renders (inside streamPageToResponse,\n // after renderToReadableStream resolves). Head tags from Suspense\n // children arrive late — this matches Next.js behavior.\n getHeadHTML: () => typeof headShim.getSSRHeadHTML === \"function\"\n ? headShim.getSSRHeadHTML()\n : \"\",\n });\n _renderEnd = now();\n\n // Clear SSR context after rendering\n if (typeof routerShim.setSSRContext === \"function\") {\n routerShim.setSSRContext(null);\n }\n\n // If ISR is enabled, we need the full HTML for caching.\n // For ISR, re-render synchronously to get the complete HTML string.\n // This runs after the stream is already sent, so it doesn't affect TTFB.\n if (isrRevalidateSeconds !== null && isrRevalidateSeconds > 0) {\n let isrElement = AppComponent\n ? createElement(AppComponent, { Component: pageModule.default, pageProps })\n : createElement(pageModule.default, pageProps);\n if (wrapWithRouterContext) {\n isrElement = wrapWithRouterContext(isrElement);\n }\n const isrBodyHtml = await renderToStringAsync(isrElement);\n const isrHtml = `<!DOCTYPE html><html><head></head><body><div id=\"__next\">${isrBodyHtml}</div>${allScripts}</body></html>`;\n const cacheKey = isrCacheKey(\"pages\", url.split(\"?\")[0]);\n await isrSet(\n cacheKey,\n buildPagesCacheValue(isrHtml, pageProps),\n isrRevalidateSeconds,\n );\n setRevalidateDuration(cacheKey, isrRevalidateSeconds);\n }\n } catch (e) {\n // Let Vite fix the stack trace for better dev experience\n server.ssrFixStacktrace(e as Error);\n console.error(e);\n // Report error via instrumentation hook if registered\n reportRequestError(\n e instanceof Error ? e : new Error(String(e)),\n {\n path: url,\n method: req.method ?? \"GET\",\n headers: Object.fromEntries(\n Object.entries(req.headers).map(([k, v]) => [k, Array.isArray(v) ? v.join(\", \") : String(v ?? \"\")]),\n ),\n },\n { routerKind: \"Pages Router\", routePath: route.pattern, routeType: \"render\" },\n ).catch(() => { /* ignore reporting errors */ });\n // Try to render custom 500 error page\n try {\n await renderErrorPage(server, req, res, url, pagesDir, 500);\n } catch (fallbackErr) {\n // If error page itself fails, fall back to plain text.\n // This is a dev-only code path (prod uses prod-server.ts), so\n // include the error message for debugging.\n res.statusCode = 500;\n res.end(`Internal Server Error: ${(fallbackErr as Error).message}`);\n }\n } finally {\n // Cleanup is handled by ALS scope unwinding —\n // each runWith*() scope is automatically cleaned up when it exits.\n }\n }) // end runWithFetchCache\n ) // end runWithPrivateCache\n ) // end _runWithCacheState\n ) // end runWithHeadState\n ); // end runWithRouterState\n };\n}\n\n/**\n * Render a custom error page (404.tsx, 500.tsx, or _error.tsx).\n *\n * Next.js resolution order:\n * - 404: pages/404.tsx -> pages/_error.tsx -> default\n * - 500: pages/500.tsx -> pages/_error.tsx -> default\n * - other: pages/_error.tsx -> default\n */\nasync function renderErrorPage(\n server: ViteDevServer,\n _req: IncomingMessage,\n res: ServerResponse,\n url: string,\n pagesDir: string,\n statusCode: number,\n wrapWithRouterContext?: ((el: React.ReactElement) => React.ReactElement) | null,\n): Promise<void> {\n // Try specific status page first, then _error, then fallback\n const candidates =\n statusCode === 404\n ? [\"404\", \"_error\"]\n : statusCode === 500\n ? [\"500\", \"_error\"]\n : [\"_error\"];\n\n for (const candidate of candidates) {\n try {\n const candidatePath = path.join(pagesDir, candidate);\n if (!findFileWithExtensions(candidatePath)) continue;\n\n const errorModule = await server.ssrLoadModule(candidatePath);\n const ErrorComponent = errorModule.default;\n if (!ErrorComponent) continue;\n\n // Try to load _app.tsx to wrap the error page\n let AppComponent: any = null;\n const appPathErr = path.join(pagesDir, \"_app\");\n if (findFileWithExtensions(appPathErr)) {\n try {\n const appModule = await server.ssrLoadModule(appPathErr);\n AppComponent = appModule.default ?? null;\n } catch {\n // _app exists but failed to load\n }\n }\n\n const createElement = React.createElement;\n const errorProps = { statusCode };\n\n // If the caller didn't supply wrapWithRouterContext, load it now.\n // ssrLoadModule caches internally so the cost is negligible.\n let wrapFn = wrapWithRouterContext;\n if (!wrapFn) {\n try {\n const errRouterShim = await server.ssrLoadModule(\"next/router\");\n wrapFn = errRouterShim.wrapWithRouterContext;\n } catch {\n // router shim not available — continue without it\n }\n }\n\n let element: React.ReactElement;\n if (AppComponent) {\n element = createElement(AppComponent, {\n Component: ErrorComponent,\n pageProps: errorProps,\n });\n } else {\n element = createElement(ErrorComponent, errorProps);\n }\n\n if (wrapFn) {\n element = wrapFn(element);\n }\n\n const bodyHtml = await renderToStringAsync(element);\n\n // Try custom _document\n let html: string;\n let DocumentComponent: any = null;\n const docPathErr = path.join(pagesDir, \"_document\");\n if (findFileWithExtensions(docPathErr)) {\n try {\n const docModule = await server.ssrLoadModule(docPathErr);\n DocumentComponent = docModule.default ?? null;\n } catch {\n // _document exists but failed to load\n }\n }\n\n if (DocumentComponent) {\n const docElement = createElement(DocumentComponent);\n let docHtml = await renderToStringAsync(docElement);\n docHtml = docHtml.replace(\"__NEXT_MAIN__\", bodyHtml);\n docHtml = docHtml.replace(\"<!-- __NEXT_SCRIPTS__ -->\", \"\");\n html = docHtml;\n } else {\n html = `<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n</head>\n<body>\n <div id=\"__next\">${bodyHtml}</div>\n</body>\n</html>`;\n }\n\n const transformedHtml = await server.transformIndexHtml(url, html);\n res.writeHead(statusCode, { \"Content-Type\": \"text/html\" });\n res.end(transformedHtml);\n return;\n } catch {\n // This candidate doesn't exist, try next\n continue;\n }\n }\n\n // No custom error page found — use plain text fallback\n res.writeHead(statusCode, { \"Content-Type\": \"text/plain\" });\n res.end(`${statusCode} - ${statusCode === 404 ? \"Page not found\" : \"Internal Server Error\"}`);\n}\n\n\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prod-server.d.ts","sourceRoot":"","sources":["../../src/server/prod-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;G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DAAmD;AACnD,QAAA,MAAM,kBAAkB,aAetB,CAAC;AAEH,0GAA0G;AAC1G,QAAA,MAAM,kBAAkB,OAAO,CAAC;AAEhC;;;GAGG;AACH,iBAAS,iBAAiB,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAQjF;AAoBD;;;GAGG;AACH,iBAAS,cAAc,CACrB,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,YAAY,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACzC,QAAQ,GAAE,OAAc,GACvB,IAAI,CAkCN;AAkGD;;;;;;;;;;;GAWG;AACH,iBAAS,WAAW,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAcnE;AAED,4EAA4E;AAC5E,QAAA,MAAM,YAAY,EAAE,GAAG,CAAC,MAAM,CAK7B,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,UAAU,SAAkE,CAAC;AAEnF;;GAEG;AACH,iBAAS,gBAAgB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAmCvD;AA+ED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,OAAO,GAAE,iBAAsB,sFA6BpE;AAkhBD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -165,6 +165,13 @@ function tryServeStatic(req, res, clientDir, pathname, compress, extraHeaders) {
|
|
|
165
165
|
catch {
|
|
166
166
|
return false;
|
|
167
167
|
}
|
|
168
|
+
// Block access to internal build metadata directories. The .vite/
|
|
169
|
+
// directory contains manifests and other build artifacts that should
|
|
170
|
+
// not be publicly served. Check after decoding to catch encoded
|
|
171
|
+
// variants like /%2Evite/manifest.json.
|
|
172
|
+
if (decodedPathname.startsWith("/.vite/") || decodedPathname === "/.vite") {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
168
175
|
const staticFile = path.resolve(clientDir, "." + decodedPathname);
|
|
169
176
|
if (!staticFile.startsWith(resolvedClient + path.sep) && staticFile !== resolvedClient) {
|
|
170
177
|
return false;
|