vinext 1.4.2 → 1.4.3
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/README.md +4 -1
- package/dist/build/prerender-paths.d.ts +11 -1
- package/dist/build/prerender-paths.js +36 -10
- package/dist/cli.js +1 -1
- package/dist/client/dev-error-overlay.d.ts +2 -1
- package/dist/client/dev-error-overlay.js +8 -3
- package/dist/config/config-matchers.js +6 -2
- package/dist/config/next-config.d.ts +9 -0
- package/dist/entries/app-rsc-entry.js +24 -12
- package/dist/entries/pages-server-entry.js +17 -4
- package/dist/index.js +22 -25
- package/dist/init-platform.js +2 -2
- package/dist/init.js +42 -5
- package/dist/server/api-handler.js +7 -3
- package/dist/server/app-browser-entry.js +16 -37
- package/dist/server/app-browser-error.d.ts +1 -1
- package/dist/server/app-browser-error.js +13 -4
- package/dist/server/app-browser-supplemental-refresh.d.ts +13 -0
- package/dist/server/app-browser-supplemental-refresh.js +36 -4
- package/dist/server/app-middleware.d.ts +2 -0
- package/dist/server/app-middleware.js +1 -0
- package/dist/server/app-page-boundary-render.js +2 -0
- package/dist/server/app-page-dispatch.d.ts +1 -0
- package/dist/server/app-page-dispatch.js +5 -1
- package/dist/server/app-page-element-builder.d.ts +2 -0
- package/dist/server/app-page-element-builder.js +2 -1
- package/dist/server/app-page-route-wiring.d.ts +7 -5
- package/dist/server/app-page-route-wiring.js +3 -1
- package/dist/server/app-pages-bridge.d.ts +6 -0
- package/dist/server/app-pages-bridge.js +8 -3
- package/dist/server/app-request-stage-independent-entry.js +2 -3
- package/dist/server/app-router-entry.js +2 -3
- package/dist/server/app-rsc-cache-busting.d.ts +8 -0
- package/dist/server/app-rsc-cache-busting.js +13 -1
- package/dist/server/app-rsc-combined-handler.js +2 -1
- package/dist/server/app-rsc-handler.d.ts +4 -0
- package/dist/server/app-rsc-handler.js +39 -22
- package/dist/server/app-rsc-response-finalizer.d.ts +15 -3
- package/dist/server/app-rsc-response-finalizer.js +51 -7
- package/dist/server/app-ssr-entry.js +8 -0
- package/dist/server/config-headers.d.ts +7 -0
- package/dist/server/config-headers.js +20 -1
- package/dist/server/image-animation.d.ts +9 -0
- package/dist/server/image-animation.js +118 -0
- package/dist/server/image-optimization.d.ts +25 -5
- package/dist/server/image-optimization.js +305 -21
- package/dist/server/image-source-reader.d.ts +34 -0
- package/dist/server/image-source-reader.js +126 -0
- package/dist/server/metadata-route-response.d.ts +6 -1
- package/dist/server/metadata-route-response.js +22 -4
- package/dist/server/middleware-matcher.d.ts +1 -0
- package/dist/server/middleware-matcher.js +1 -1
- package/dist/server/middleware-runtime.d.ts +5 -0
- package/dist/server/middleware-runtime.js +48 -15
- package/dist/server/middleware.d.ts +1 -1
- package/dist/server/middleware.js +2 -1
- package/dist/server/nitro-request-target-plugin.d.ts +17 -0
- package/dist/server/nitro-request-target-plugin.js +22 -0
- package/dist/server/open-redirect.d.ts +2 -1
- package/dist/server/open-redirect.js +2 -1
- package/dist/server/pages-client-assets.d.ts +1 -0
- package/dist/server/pages-i18n.d.ts +7 -0
- package/dist/server/pages-i18n.js +14 -1
- package/dist/server/pages-node-compat.js +7 -3
- package/dist/server/pages-page-handler.js +4 -4
- package/dist/server/pages-request-pipeline.d.ts +9 -0
- package/dist/server/pages-request-pipeline.js +29 -10
- package/dist/server/pages-request-stage-entry.js +7 -2
- package/dist/server/pages-router-entry.js +3 -0
- package/dist/server/prod-server.d.ts +1 -1
- package/dist/server/prod-server.js +48 -54
- package/dist/server/srvx-middleware-origin.d.ts +13 -0
- package/dist/server/srvx-middleware-origin.js +19 -0
- package/dist/server/srvx-request-target.d.ts +12 -0
- package/dist/server/srvx-request-target.js +20 -0
- package/dist/server/static-file-cache.js +10 -22
- package/dist/server/worker-image-optimization.d.ts +8 -1
- package/dist/server/worker-image-optimization.js +25 -6
- package/dist/server/worker-revalidation-context.js +1 -0
- package/dist/shims/error-boundary.d.ts +6 -2
- package/dist/shims/error-boundary.js +4 -2
- package/dist/shims/request-context.d.ts +3 -1
- package/dist/shims/url-utils.js +6 -1
- package/dist/utils/client-entry-manifest.d.ts +5 -0
- package/dist/utils/client-entry-manifest.js +1 -0
- package/dist/utils/client-runtime-metadata.d.ts +5 -0
- package/dist/utils/client-runtime-metadata.js +33 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -137,10 +137,13 @@ files to `.cjs`) when an unambiguous default Vite config requires the ESM migrat
|
|
|
137
137
|
`"type": "commonjs"` is never changed. Direct `vite dev` and `vite build` do not perform these
|
|
138
138
|
wrapper compatibility steps.
|
|
139
139
|
|
|
140
|
-
`@vinext/cloudflare deploy` options: `--preview`, `--env <name>`, `--name <name
|
|
140
|
+
`@vinext/cloudflare deploy` options: `--preview`, `--env <name>`, `--name <name>` (Wrangler config projects only), `--vite-config <path>`, `--skip-build`, `--dry-run`, `--warm-cache`, `--traffic-aware-warm-cache`.
|
|
141
141
|
|
|
142
142
|
`vinext init` prompts for a deployment target, defaulting to Cloudflare. Agents must ask the
|
|
143
143
|
user which target they want, then pass `--platform=cloudflare` or `--platform=node`.
|
|
144
|
+
For Cloudflare, agents and CI must also pass `--cdn-cache`, `--data-cache`, and
|
|
145
|
+
`--image-optimization`; see
|
|
146
|
+
[Run init without prompts](https://vinext.dev/docs/deploying/cloudflare#run-init-without-prompts).
|
|
144
147
|
|
|
145
148
|
Other options: `--port <port>` (default: 3001), `--skip-check`, `--force`.
|
|
146
149
|
|
|
@@ -91,7 +91,17 @@ type PrerenderPathDiscoveryOptions = {
|
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
93
|
/** @internal Match the pathname forms and locale provenance used by middleware runtime. */
|
|
94
|
-
export declare function matchesMiddlewareWarmPath(pathname: string, matcher: MatcherConfig | undefined, i18n: ResolvedNextConfig["i18n"]
|
|
94
|
+
export declare function matchesMiddlewareWarmPath(pathname: string, matcher: MatcherConfig | undefined, i18n: ResolvedNextConfig["i18n"], options?: {
|
|
95
|
+
basePath?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the path's Pages data request reaches middleware slashed
|
|
98
|
+
* (`shouldAddTrailingSlashToPagesDataPath`). Omit for a path without a
|
|
99
|
+
* Pages data target.
|
|
100
|
+
*/
|
|
101
|
+
pagesDataTrailingSlash?: boolean;
|
|
102
|
+
skipProxyUrlNormalize?: boolean;
|
|
103
|
+
trailingSlash?: boolean;
|
|
104
|
+
}): boolean;
|
|
95
105
|
export declare function discoverPrerenderPathManifest(options: PrerenderPathDiscoveryOptions): Promise<PrerenderPathManifest | null>;
|
|
96
106
|
export declare function emitPrerenderPathManifest(options: PrerenderPathDiscoveryOptions): Promise<PrerenderPathManifest | null>;
|
|
97
107
|
//#endregion
|
|
@@ -10,6 +10,7 @@ import { appRouteHasMainTreeLoadingBoundary, appRouter, matchAppRoute } from "..
|
|
|
10
10
|
import { apiRouter, matchRoute, pagesRouter } from "../routing/pages-router.js";
|
|
11
11
|
import { matchesMiddlewarePathname } from "../server/middleware-matcher.js";
|
|
12
12
|
import { extractLocaleFromUrl, normalizeDefaultLocalePathname, shouldRestoreLocaleRootTrailingSlash } from "../server/pages-i18n.js";
|
|
13
|
+
import { normalizeNextDataPagePathname, shouldAddTrailingSlashToPagesDataPath } from "../server/pages-data-route.js";
|
|
13
14
|
import { classifyAppRoute, classifyAppRouteHandler, classifyPagesRoute, extractExportConstString, extractMiddlewareMatcherConfig, getAppRouteRenderEntryPath } from "./report.js";
|
|
14
15
|
import { normalizeStaticPathname, normalizeStaticPathsEntry } from "../routing/route-pattern.js";
|
|
15
16
|
import { buildPagesDataHref } from "../shims/internal/pages-data-url.js";
|
|
@@ -684,19 +685,37 @@ function findMiddlewareConventionFile(root, appDir, pagesDir, pageExtensions) {
|
|
|
684
685
|
return null;
|
|
685
686
|
}
|
|
686
687
|
/** @internal Match the pathname forms and locale provenance used by middleware runtime. */
|
|
687
|
-
function matchesMiddlewareWarmPath(pathname, matcher, i18n) {
|
|
688
|
+
function matchesMiddlewareWarmPath(pathname, matcher, i18n, options = {}) {
|
|
688
689
|
const encodedPathname = new URL(pathname, "https://vinext.invalid").pathname;
|
|
690
|
+
const trailingSlash = options.trailingSlash ?? false;
|
|
691
|
+
const htmlRequestPathname = normalizePathTrailingSlash(options.basePath ? `${options.basePath}${encodedPathname === "/" ? "" : encodedPathname}` : encodedPathname, trailingSlash);
|
|
689
692
|
const firstSegment = encodedPathname.split("/", 3)[1]?.toLowerCase();
|
|
690
693
|
const localeContexts = i18n ? i18n.locales.some((locale) => locale.toLowerCase() === firstSegment) ? [{ kind: "literal" }] : Array.from(/* @__PURE__ */ new Set([i18n.defaultLocale, ...i18n.domains?.map((domain) => domain.defaultLocale) ?? []]), (defaultLocale) => ({
|
|
691
694
|
defaultLocale,
|
|
692
695
|
kind: "defaulted"
|
|
693
696
|
})) : [void 0];
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
697
|
+
const requestSpellings = [{
|
|
698
|
+
localeContexts: shouldRestoreLocaleRootTrailingSlash(htmlRequestPathname, options) ? localeContexts.map((localeContext) => localeContext?.kind === "defaulted" ? {
|
|
699
|
+
...localeContext,
|
|
700
|
+
restoreRootTrailingSlash: true
|
|
701
|
+
} : localeContext) : localeContexts,
|
|
702
|
+
pathname: normalizePathTrailingSlash(encodedPathname, trailingSlash)
|
|
703
|
+
}];
|
|
704
|
+
if (options.pagesDataTrailingSlash !== void 0) {
|
|
705
|
+
const dataLocaleContexts = [i18n ? { kind: "literal" } : void 0];
|
|
706
|
+
requestSpellings.push({
|
|
707
|
+
localeContexts: dataLocaleContexts,
|
|
708
|
+
pathname: normalizeNextDataPagePathname(localizePagesDataPath(encodedPathname, i18n), options.pagesDataTrailingSlash)
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
return requestSpellings.some((spelling) => {
|
|
712
|
+
const matchPathnames = [spelling.pathname];
|
|
713
|
+
try {
|
|
714
|
+
const decodedPathname = decodeURIComponent(spelling.pathname);
|
|
715
|
+
if (decodedPathname !== spelling.pathname) matchPathnames.push(decodedPathname);
|
|
716
|
+
} catch {}
|
|
717
|
+
return matchPathnames.some((matchPathname) => spelling.localeContexts.some((localeContext) => matchesMiddlewarePathname(matchPathname, matcher, i18n, localeContext)));
|
|
718
|
+
});
|
|
700
719
|
}
|
|
701
720
|
async function startPathDiscoveryServer(options) {
|
|
702
721
|
return startProdServer({
|
|
@@ -822,10 +841,7 @@ async function discoverPrerenderPathManifest(options) {
|
|
|
822
841
|
const hasStagedRequestRouting = options.requestRouting === "uncached-stage";
|
|
823
842
|
const middlewarePath = hasStagedRequestRouting ? findMiddlewareConventionFile(root, appDir, pagesDir, config.pageExtensions) : null;
|
|
824
843
|
const configuredMatcher = middlewarePath ? extractMiddlewareMatcherConfig(middlewarePath) : void 0;
|
|
825
|
-
const middlewareMayRouteWarmPath = (pathname) => middlewarePath !== null && matchesMiddlewareWarmPath(pathname, configuredMatcher, config.i18n);
|
|
826
844
|
const routedWarmPaths = [...paths, ...discoveredRouteHandlerPaths];
|
|
827
|
-
const routeMayResolveWarmPathSet = new Set(hasStagedRequestRouting ? routedWarmPaths.filter((pathname) => middlewareMayRouteWarmPath(pathname) || configuredRewritesCanReplaceWarmPath(pathname, config.rewrites, discoveredNonDynamicPathSet.has(pathname), config, (rewrite) => !isExternalUrl(rewrite.destination))) : []);
|
|
828
|
-
const requestStageMayTerminateWarmPathSet = new Set(hasStagedRequestRouting ? routedWarmPaths.filter((pathname) => middlewareMayRouteWarmPath(pathname) || configuredRulesAffectWarmPath(pathname, config.redirects, config) || configuredRewritesCanReplaceWarmPath(pathname, config.rewrites, discoveredNonDynamicPathSet.has(pathname), config, (rewrite) => isExternalUrl(rewrite.destination))) : []);
|
|
829
845
|
const excludedWarmPathSet = new Set(options.responseVary && !hasStagedRequestRouting ? routedWarmPaths.filter((pathname) => configuredRulesAffectWarmPath(pathname, config.redirects, config) || configuredRewritesCanReplaceWarmPath(pathname, config.rewrites, discoveredNonDynamicPathSet.has(pathname), config, () => true)) : []);
|
|
830
846
|
const configuredPagesWarmPaths = discoveredPagesPaths.filter((pathname) => !excludedWarmPathSet.has(pathname));
|
|
831
847
|
const resolvedPagesWarmPaths = !appDir && pagesDir ? await excludePagesApiWarmPaths({
|
|
@@ -864,6 +880,16 @@ async function discoverPrerenderPathManifest(options) {
|
|
|
864
880
|
routePatterns: pagesWarmMetadata.routePatterns,
|
|
865
881
|
rscPaths: []
|
|
866
882
|
};
|
|
883
|
+
const pagesDataRequestsGetTrailingSlash = shouldAddTrailingSlashToPagesDataPath(true, config.trailingSlash, config.skipProxyUrlNormalize);
|
|
884
|
+
const pagesOwnedPathSet = appDir ? new Set(appOwnedWarmPaths.pagesPaths) : null;
|
|
885
|
+
const middlewareMatchesWarmPath = (pathname) => middlewarePath !== null && matchesMiddlewareWarmPath(pathname, configuredMatcher, config.i18n, {
|
|
886
|
+
basePath: config.basePath,
|
|
887
|
+
pagesDataTrailingSlash: discoveredPagesDataPathSet.has(pathname) && (pagesOwnedPathSet?.has(pathname) ?? true) ? pagesDataRequestsGetTrailingSlash : void 0,
|
|
888
|
+
skipProxyUrlNormalize: config.skipProxyUrlNormalize,
|
|
889
|
+
trailingSlash: config.trailingSlash
|
|
890
|
+
});
|
|
891
|
+
const routeMayResolveWarmPathSet = new Set(hasStagedRequestRouting ? routedWarmPaths.filter((pathname) => middlewareMatchesWarmPath(pathname) || configuredRewritesCanReplaceWarmPath(pathname, config.rewrites, discoveredNonDynamicPathSet.has(pathname), config, (rewrite) => !isExternalUrl(rewrite.destination))) : []);
|
|
892
|
+
const requestStageMayTerminateWarmPathSet = new Set(hasStagedRequestRouting ? routedWarmPaths.filter((pathname) => middlewareMatchesWarmPath(pathname) || configuredRulesAffectWarmPath(pathname, config.redirects, config) || configuredRewritesCanReplaceWarmPath(pathname, config.rewrites, discoveredNonDynamicPathSet.has(pathname), config, (rewrite) => isExternalUrl(rewrite.destination))) : []);
|
|
867
893
|
for (const pathname of configuredCandidatePaths) {
|
|
868
894
|
if (appOwnedWarmPaths.routePatterns[pathname] || !routeMayResolveWarmPathSet.has(pathname) && !requestStageMayTerminateWarmPathSet.has(pathname)) continue;
|
|
869
895
|
appOwnedWarmPaths.htmlPaths.push(pathname);
|
package/dist/cli.js
CHANGED
|
@@ -281,7 +281,7 @@ function printHelp(cmd) {
|
|
|
281
281
|
--prerender Configure Vite builds to pre-render static routes
|
|
282
282
|
(Cloudflare deploy won't serve them unless using Static Assets)
|
|
283
283
|
--warm-cache Add cache warming to the Cloudflare deploy script
|
|
284
|
-
(
|
|
284
|
+
(requires a --cdn-cache other than none, default: prompt with No)
|
|
285
285
|
--legacy-wrangler-cloudflare-init
|
|
286
286
|
Use the legacy Wrangler setup instead of cf
|
|
287
287
|
--ignore-wrangler-config
|
|
@@ -5,7 +5,8 @@ export declare const DEV_ERROR_OVERLAY_HOST_ID = "__vinext_dev_error_overlay_roo
|
|
|
5
5
|
export declare const DEV_ERROR_OVERLAY_MOUNT_ID = "__vinext_dev_error_overlay_mount";
|
|
6
6
|
export declare function installDevErrorOverlay(): void;
|
|
7
7
|
export declare function installReactRefreshErrorRecovery(): void;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function reportRootErrorBoundaryCatch(): void;
|
|
9
|
+
export declare function selectUnreportedInitialDevServerErrors(payloads: readonly InitialDevServerErrorPayload[], reported: readonly ReportedError[], rootBoundaryCaught?: boolean): InitialDevServerErrorPayload[];
|
|
9
10
|
export declare function reportInitialDevServerErrors(): void;
|
|
10
11
|
type ViteHmrErrorPayload = {
|
|
11
12
|
err?: ViteHmrError;
|
|
@@ -82,7 +82,12 @@ function tryInstallReactRefreshErrorRecovery() {
|
|
|
82
82
|
});
|
|
83
83
|
return true;
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
let rootErrorBoundaryCaught = false;
|
|
86
|
+
function reportRootErrorBoundaryCatch() {
|
|
87
|
+
rootErrorBoundaryCaught = true;
|
|
88
|
+
}
|
|
89
|
+
function selectUnreportedInitialDevServerErrors(payloads, reported, rootBoundaryCaught = false) {
|
|
90
|
+
if (rootBoundaryCaught) return [];
|
|
86
91
|
const rethrownErrors = reported.filter((error) => error.source === "caught" || error.source === "uncaught" || error.source === "window-error");
|
|
87
92
|
return payloads.filter((payload) => {
|
|
88
93
|
const rethrownIndex = rethrownErrors.findIndex((error) => error.message === payload.message && (error.name || "Error") === (payload.name || "Error"));
|
|
@@ -96,7 +101,7 @@ function reportInitialDevServerErrors() {
|
|
|
96
101
|
const errors = window.__VINEXT_INITIAL_DEV_ERRORS__;
|
|
97
102
|
if (!errors || errors.length === 0) return;
|
|
98
103
|
window.__VINEXT_INITIAL_DEV_ERRORS__ = [];
|
|
99
|
-
for (const payload of selectUnreportedInitialDevServerErrors(errors, getOverlaySnapshot().errors)) {
|
|
104
|
+
for (const payload of selectUnreportedInitialDevServerErrors(errors, getOverlaySnapshot().errors, rootErrorBoundaryCaught)) {
|
|
100
105
|
const error = new Error(payload.message);
|
|
101
106
|
if (payload.name) error.name = payload.name;
|
|
102
107
|
if (payload.stack) error.stack = payload.stack;
|
|
@@ -1358,4 +1363,4 @@ const componentStackStyle = {
|
|
|
1358
1363
|
color: "var(--vinext-overlay-muted)"
|
|
1359
1364
|
};
|
|
1360
1365
|
//#endregion
|
|
1361
|
-
export { DEV_ERROR_OVERLAY_HOST_ID, DEV_ERROR_OVERLAY_MOUNT_ID, createDevErrorOverlayMountNode, createViteOpenInEditorUrl, devOnCaughtError, devOnUncaughtError, dismissOverlay, formatErrorInfoForClipboard, formatOverlayDisplayFile, formatViteOpenInEditorFile, installDevErrorOverlay, installReactRefreshErrorRecovery, installViteHmrErrorHandler, normalizeViteHmrError, reportInitialDevServerErrors, selectUnreportedInitialDevServerErrors };
|
|
1366
|
+
export { DEV_ERROR_OVERLAY_HOST_ID, DEV_ERROR_OVERLAY_MOUNT_ID, createDevErrorOverlayMountNode, createViteOpenInEditorUrl, devOnCaughtError, devOnUncaughtError, dismissOverlay, formatErrorInfoForClipboard, formatOverlayDisplayFile, formatViteOpenInEditorFile, installDevErrorOverlay, installReactRefreshErrorRecovery, installViteHmrErrorHandler, normalizeViteHmrError, reportInitialDevServerErrors, reportRootErrorBoundaryCatch, selectUnreportedInitialDevServerErrors };
|
|
@@ -179,10 +179,14 @@ const REQUEST_HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
|
179
179
|
"transfer-encoding",
|
|
180
180
|
"upgrade"
|
|
181
181
|
]);
|
|
182
|
+
/**
|
|
183
|
+
* Strip the fixed request hop-by-hop list. Fields the client nominates in
|
|
184
|
+
* `Connection` are forwarded, like Next.js: the headers here already include
|
|
185
|
+
* middleware's request overrides, so honouring the client's list would let it
|
|
186
|
+
* drop headers middleware set.
|
|
187
|
+
*/
|
|
182
188
|
function stripHopByHopRequestHeaders(headers) {
|
|
183
|
-
const connectionTokens = (headers.get("connection") || "").split(",").map((value) => value.trim().toLowerCase()).filter(Boolean);
|
|
184
189
|
for (const header of REQUEST_HOP_BY_HOP_HEADERS) headers.delete(header);
|
|
185
|
-
for (const token of connectionTokens) headers.delete(token);
|
|
186
190
|
}
|
|
187
191
|
/**
|
|
188
192
|
* Compile a regex from next.config, or return null when it is invalid.
|
|
@@ -213,6 +213,15 @@ export type NextConfig = {
|
|
|
213
213
|
contentDispositionType?: "inline" | "attachment";
|
|
214
214
|
/** Content-Security-Policy header for image responses. Defaults to "script-src 'none'; frame-src 'none'; sandbox;" */
|
|
215
215
|
contentSecurityPolicy?: string;
|
|
216
|
+
/** Least max-age, in seconds, of an image the endpoint serves as-is. Defaults to 14400. */
|
|
217
|
+
minimumCacheTTL?: number;
|
|
218
|
+
/**
|
|
219
|
+
* Most bytes the endpoint reads of a GIF, PNG or WebP source bound for an
|
|
220
|
+
* image optimizer (while detecting animation and while streaming to the
|
|
221
|
+
* optimizer) before answering 413. Other sources stream unbounded.
|
|
222
|
+
* Defaults to 50000000.
|
|
223
|
+
*/
|
|
224
|
+
maximumResponseBody?: number;
|
|
216
225
|
};
|
|
217
226
|
/**
|
|
218
227
|
* Enable React Strict Mode. When `true`, the client root is wrapped in
|
|
@@ -122,8 +122,7 @@ function buildAppDecodedPathnamePatterns(routes, config) {
|
|
|
122
122
|
};
|
|
123
123
|
return routes.filter((route) => !route.isDynamic && !route.routePath && getAppRouteRenderEntryPath(route) !== null && isPrerenderedPage(route)).map((route) => route.pattern);
|
|
124
124
|
}
|
|
125
|
-
function createForcesDynamicReader() {
|
|
126
|
-
const readSource = createSegmentSourceReader();
|
|
125
|
+
function createForcesDynamicReader(readSource = createSegmentSourceReader()) {
|
|
127
126
|
return (filePath) => {
|
|
128
127
|
const source = readSource(filePath);
|
|
129
128
|
return source !== null && extractExportConstString(source, "dynamic") === "force-dynamic";
|
|
@@ -134,7 +133,13 @@ function directRequestForcesDynamic(route, forcesDynamic) {
|
|
|
134
133
|
return route.routePath ? forcesDynamic(route.routePath) : appPageSegmentConfigPaths(route).some(forcesDynamic);
|
|
135
134
|
}
|
|
136
135
|
function buildAppRequestRouteMetadata(routes) {
|
|
137
|
-
const
|
|
136
|
+
const readSource = createSegmentSourceReader();
|
|
137
|
+
const forcesDynamic = createForcesDynamicReader(readSource);
|
|
138
|
+
const routeHandlerMetadata = (filePath) => {
|
|
139
|
+
const source = readSource(filePath);
|
|
140
|
+
const runtime = source === null ? null : extractExportConstString(source, "runtime");
|
|
141
|
+
return runtime ? { runtime } : true;
|
|
142
|
+
};
|
|
138
143
|
return routes.map((route) => ({
|
|
139
144
|
canUseCanonicalLoadingShell: appRouteHasMainTreeLoadingBoundary(route),
|
|
140
145
|
forceDynamic: directRequestForcesDynamic(route, forcesDynamic) || [...route.parallelSlots.flatMap((slot) => slot.interceptingRoutes.flatMap((intercept) => [...intercept.layoutPaths, intercept.pagePath])), ...route.siblingIntercepts.flatMap((intercept) => [...intercept.layoutPaths, intercept.pagePath])].some(forcesDynamic),
|
|
@@ -145,7 +150,7 @@ function buildAppRequestRouteMetadata(routes) {
|
|
|
145
150
|
params: route.params,
|
|
146
151
|
rootParamNames: route.rootParamNames ?? [],
|
|
147
152
|
page: route.pagePath ? true : null,
|
|
148
|
-
routeHandler: route.routePath ?
|
|
153
|
+
routeHandler: route.routePath ? routeHandlerMetadata(route.routePath) : null,
|
|
149
154
|
routeSegments: route.routeSegments,
|
|
150
155
|
layouts: [],
|
|
151
156
|
layoutTreePositions: [],
|
|
@@ -292,7 +297,9 @@ export const __imageConfig = ${JSON.stringify({
|
|
|
292
297
|
dangerouslyAllowSVG: config?.imageConfig?.dangerouslyAllowSVG,
|
|
293
298
|
dangerouslyAllowLocalIP: config?.imageConfig?.dangerouslyAllowLocalIP,
|
|
294
299
|
contentDispositionType: config?.imageConfig?.contentDispositionType,
|
|
295
|
-
contentSecurityPolicy: config?.imageConfig?.contentSecurityPolicy
|
|
300
|
+
contentSecurityPolicy: config?.imageConfig?.contentSecurityPolicy,
|
|
301
|
+
minimumCacheTTL: config?.imageConfig?.minimumCacheTTL,
|
|
302
|
+
maximumResponseBody: config?.imageConfig?.maximumResponseBody
|
|
296
303
|
})};
|
|
297
304
|
export const __clientBuildFiles = __pagesClientAssets.clientBuildFiles ?? [];
|
|
298
305
|
// The matcher reads recorded prerenders, and this stage can run without the
|
|
@@ -385,7 +392,7 @@ const __requestHandler = createAppRscRequestHandler({
|
|
|
385
392
|
params: pickParams(route, intercept.sourceMatchedParams),
|
|
386
393
|
};
|
|
387
394
|
},
|
|
388
|
-
${middlewarePath ? `runMiddleware({ cleanPathname, context, externalRewriteRequest, hadBasePath, isDataRequest, middlewareRequest, request, validateExternalRewriteRequest }) {
|
|
395
|
+
${middlewarePath ? `runMiddleware({ cleanPathname, context, externalRewriteRequest, hadBasePath, isDataRequest, middlewareRequest, request, restoreLocaleRootTrailingSlash, validateExternalRewriteRequest }) {
|
|
389
396
|
return __applyAppMiddleware({
|
|
390
397
|
basePath: __basePath,
|
|
391
398
|
cleanPathname,
|
|
@@ -399,6 +406,7 @@ const __requestHandler = createAppRscRequestHandler({
|
|
|
399
406
|
middlewareRequest,
|
|
400
407
|
module: middlewareModule,
|
|
401
408
|
request,
|
|
409
|
+
restoreLocaleRootTrailingSlash,
|
|
402
410
|
skipTrailingSlashRedirect: ${JSON.stringify(config?.skipTrailingSlashRedirect ?? false)},
|
|
403
411
|
trailingSlash: __trailingSlash,
|
|
404
412
|
validateExternalRewriteRequest,
|
|
@@ -407,9 +415,9 @@ const __requestHandler = createAppRscRequestHandler({
|
|
|
407
415
|
publicFiles: new Set(${JSON.stringify(config?.publicFiles ?? [])}),
|
|
408
416
|
registerCacheAdapters: __registerConfiguredCacheAdapters,
|
|
409
417
|
renderNotFound: async () => null,
|
|
410
|
-
${hasPagesDir ? `async renderPagesFallback({ allowRscDocumentFallback, appRouteMatch, dispatchPagesResponseStage, initialResponseHeaders, isDataRequest, isRscRequest, matchKind, middlewareContext, pathname, pagesDataRequest, request, sharedAcrossHosts, url }) {
|
|
418
|
+
${hasPagesDir ? `async renderPagesFallback({ allowRscDocumentFallback, appRouteMatch, dispatchPagesResponseStage, initialResponseHeaders, isDataRequest, isRscRequest, matchKind, middlewareContext, pathname, pagesDataRequest, request, requestBasePath, sharedAcrossHosts, url }) {
|
|
411
419
|
return __renderPagesFallback(
|
|
412
|
-
{ allowRscDocumentFallback, appRouteMatch, initialResponseHeaders, isDataRequest, isRscRequest, matchKind, middlewareContext, pathname, pagesDataRequest, request, sharedAcrossHosts, url },
|
|
420
|
+
{ allowRscDocumentFallback, appRouteMatch, initialResponseHeaders, isDataRequest, isRscRequest, matchKind, middlewareContext, pathname, pagesDataRequest, request, requestBasePath, sharedAcrossHosts, url },
|
|
413
421
|
{
|
|
414
422
|
async loadPagesEntry() {
|
|
415
423
|
if (!dispatchPagesResponseStage) {
|
|
@@ -504,7 +512,9 @@ function generateRscEntry(appDir, routes, middlewarePath, metadataRoutes, global
|
|
|
504
512
|
dangerouslyAllowSVG: config?.imageConfig?.dangerouslyAllowSVG,
|
|
505
513
|
dangerouslyAllowLocalIP: config?.imageConfig?.dangerouslyAllowLocalIP,
|
|
506
514
|
contentDispositionType: config?.imageConfig?.contentDispositionType,
|
|
507
|
-
contentSecurityPolicy: config?.imageConfig?.contentSecurityPolicy
|
|
515
|
+
contentSecurityPolicy: config?.imageConfig?.contentSecurityPolicy,
|
|
516
|
+
minimumCacheTTL: config?.imageConfig?.minimumCacheTTL,
|
|
517
|
+
maximumResponseBody: config?.imageConfig?.maximumResponseBody
|
|
508
518
|
};
|
|
509
519
|
const { imports, importInitializers, routeEntries, metaRouteEntries, generateStaticParamsEntries, rootParamNameEntries, rootNotFoundVar, rootForbiddenVar, rootUnauthorizedVar, rootLayoutVars, globalErrorVar, globalNotFoundImportSpecifier } = buildAppRscManifestCode({
|
|
510
520
|
deferEagerImports: Boolean(instrumentationPath),
|
|
@@ -1143,6 +1153,7 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
|
|
|
1143
1153
|
observePageSearchParamsAccess: buildOptions?.observePageSearchParamsAccess === true,
|
|
1144
1154
|
isForceStatic: buildOptions?.isForceStatic === true,
|
|
1145
1155
|
isUncacheableRender: buildOptions?.isUncacheableRender === true,
|
|
1156
|
+
routeTreeOnlyPrefetchShell: buildOptions?.routeTreeOnlyPrefetchShell === true,
|
|
1146
1157
|
mountedLayouts: buildOptions?.mountedLayouts ?? null,
|
|
1147
1158
|
serveStreamingMetadata: buildOptions?.serveStreamingMetadata,
|
|
1148
1159
|
placeStreamedMetadataInHead: buildOptions?.placeStreamedMetadataInHead === true,
|
|
@@ -1671,7 +1682,7 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
|
|
|
1671
1682
|
params: pickParams(route, intercept.sourceMatchedParams),
|
|
1672
1683
|
};
|
|
1673
1684
|
},
|
|
1674
|
-
${middlewarePath ? `runMiddleware({ cleanPathname, context, externalRewriteRequest, hadBasePath, isDataRequest, middlewareRequest, request, validateExternalRewriteRequest }) {
|
|
1685
|
+
${middlewarePath ? `runMiddleware({ cleanPathname, context, externalRewriteRequest, hadBasePath, isDataRequest, middlewareRequest, request, restoreLocaleRootTrailingSlash, validateExternalRewriteRequest }) {
|
|
1675
1686
|
return __applyAppMiddleware({
|
|
1676
1687
|
basePath: __basePath,
|
|
1677
1688
|
cleanPathname,
|
|
@@ -1685,6 +1696,7 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
|
|
|
1685
1696
|
middlewareRequest,
|
|
1686
1697
|
module: middlewareModule,
|
|
1687
1698
|
request,
|
|
1699
|
+
restoreLocaleRootTrailingSlash,
|
|
1688
1700
|
skipTrailingSlashRedirect: ${JSON.stringify(config?.skipTrailingSlashRedirect ?? false)},
|
|
1689
1701
|
trailingSlash: __trailingSlash,
|
|
1690
1702
|
validateExternalRewriteRequest,
|
|
@@ -1695,9 +1707,9 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
|
|
|
1695
1707
|
const __isEdge = route ? __isEdgeRuntime(__resolveRouteRuntime(route)) : false;
|
|
1696
1708
|
return __fallbackRenderer.renderNotFound(route, isRscRequest, request, matchedParams, scriptNonce, middlewareContext, { isEdgeRuntime: __isEdge });
|
|
1697
1709
|
},
|
|
1698
|
-
${hasPagesDir ? `async renderPagesFallback({ allowRscDocumentFallback, appRouteMatch, dispatchPagesResponseStage, initialResponseHeaders, isDataRequest, isRscRequest, matchKind, middlewareContext, pathname, pagesDataRequest, request, sharedAcrossHosts, url }) {
|
|
1710
|
+
${hasPagesDir ? `async renderPagesFallback({ allowRscDocumentFallback, appRouteMatch, dispatchPagesResponseStage, initialResponseHeaders, isDataRequest, isRscRequest, matchKind, middlewareContext, pathname, pagesDataRequest, request, requestBasePath, sharedAcrossHosts, url }) {
|
|
1699
1711
|
return __renderPagesFallback(
|
|
1700
|
-
{ allowRscDocumentFallback, appRouteMatch, initialResponseHeaders, isDataRequest, isRscRequest, matchKind, middlewareContext, pathname, pagesDataRequest, request, sharedAcrossHosts, url },
|
|
1712
|
+
{ allowRscDocumentFallback, appRouteMatch, initialResponseHeaders, isDataRequest, isRscRequest, matchKind, middlewareContext, pathname, pagesDataRequest, request, requestBasePath, sharedAcrossHosts, url },
|
|
1701
1713
|
{
|
|
1702
1714
|
async loadPagesEntry() {
|
|
1703
1715
|
const __pagesEntry = await __ensureHybridPagesApplication();
|
|
@@ -108,7 +108,9 @@ async function generatePagesRequestEntry(pagesDir, nextConfig, fileMatcher, midd
|
|
|
108
108
|
dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,
|
|
109
109
|
dangerouslyAllowLocalIP: nextConfig?.images?.dangerouslyAllowLocalIP,
|
|
110
110
|
contentDispositionType: nextConfig?.images?.contentDispositionType,
|
|
111
|
-
contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy
|
|
111
|
+
contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy,
|
|
112
|
+
minimumCacheTTL: nextConfig?.images?.minimumCacheTTL,
|
|
113
|
+
maximumResponseBody: nextConfig?.images?.maximumResponseBody
|
|
112
114
|
}
|
|
113
115
|
});
|
|
114
116
|
const instrumentationImportCode = instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(instrumentationPath)};
|
|
@@ -135,6 +137,7 @@ export function __ensureInstrumentation(ctx) {
|
|
|
135
137
|
isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
|
|
136
138
|
module: middlewareModule,
|
|
137
139
|
request,
|
|
140
|
+
restoreLocaleRootTrailingSlash: options?.restoreLocaleRootTrailingSlash === true,
|
|
138
141
|
skipTrailingSlashRedirect: vinextConfig.skipTrailingSlashRedirect,
|
|
139
142
|
trailingSlash: vinextConfig.trailingSlash,
|
|
140
143
|
});
|
|
@@ -165,11 +168,14 @@ export const vinextConfig = ${vinextConfigJson};
|
|
|
165
168
|
export const publicFiles = new Set(${JSON.stringify(publicFiles)});
|
|
166
169
|
export const clientBuildFiles = new Set(__pagesClientAssets.clientBuildFiles ?? []);
|
|
167
170
|
|
|
171
|
+
// The Worker request stage strips basePath before calling this, so the data
|
|
172
|
+
// path must not lose it again: with basePath "/docs", "/docs/docs/_next/data/..."
|
|
173
|
+
// is the page path "/docs/_next/data/...", not a data request.
|
|
168
174
|
export function normalizeDataRequest(request) {
|
|
169
175
|
return __normalizePagesDataRequest(
|
|
170
176
|
request,
|
|
171
177
|
buildId,
|
|
172
|
-
|
|
178
|
+
"",
|
|
173
179
|
__shouldAddTrailingSlashToPagesDataPath(
|
|
174
180
|
hasMiddleware,
|
|
175
181
|
vinextConfig.trailingSlash,
|
|
@@ -286,7 +292,9 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
|
|
|
286
292
|
dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,
|
|
287
293
|
dangerouslyAllowLocalIP: nextConfig?.images?.dangerouslyAllowLocalIP,
|
|
288
294
|
contentDispositionType: nextConfig?.images?.contentDispositionType,
|
|
289
|
-
contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy
|
|
295
|
+
contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy,
|
|
296
|
+
minimumCacheTTL: nextConfig?.images?.minimumCacheTTL,
|
|
297
|
+
maximumResponseBody: nextConfig?.images?.maximumResponseBody
|
|
290
298
|
}
|
|
291
299
|
});
|
|
292
300
|
const instrumentationImportCode = instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(instrumentationPath)};
|
|
@@ -333,6 +341,7 @@ export async function runMiddleware(request, ctx, options) {
|
|
|
333
341
|
isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
|
|
334
342
|
module: middlewareModule,
|
|
335
343
|
request,
|
|
344
|
+
restoreLocaleRootTrailingSlash: options?.restoreLocaleRootTrailingSlash === true,
|
|
336
345
|
skipTrailingSlashRedirect: vinextConfig.skipTrailingSlashRedirect,
|
|
337
346
|
trailingSlash: vinextConfig.trailingSlash,
|
|
338
347
|
});
|
|
@@ -400,11 +409,14 @@ export const buildId = ${buildIdJson};
|
|
|
400
409
|
// Per-build capability used by Worker entries to authorize remote path
|
|
401
410
|
// discovery. It is never included in responses or exposed to user modules.
|
|
402
411
|
export const prerenderSecret = ${JSON.stringify(prerenderSecret ?? null)};
|
|
412
|
+
// The Worker request stage strips basePath before calling this, so the data
|
|
413
|
+
// path must not lose it again: with basePath "/docs", "/docs/docs/_next/data/..."
|
|
414
|
+
// is the page path "/docs/_next/data/...", not a data request.
|
|
403
415
|
export function normalizeDataRequest(request) {
|
|
404
416
|
return __normalizePagesDataRequest(
|
|
405
417
|
request,
|
|
406
418
|
buildId,
|
|
407
|
-
|
|
419
|
+
"",
|
|
408
420
|
__shouldAddTrailingSlashToPagesDataPath(
|
|
409
421
|
hasMiddleware,
|
|
410
422
|
vinextConfig.trailingSlash,
|
|
@@ -439,6 +451,7 @@ export const pageRoutes = [
|
|
|
439
451
|
${pageRouteEntries.join(",\n")}
|
|
440
452
|
];
|
|
441
453
|
export const publicFiles = new Set(${JSON.stringify(publicFiles)});
|
|
454
|
+
export const clientBuildFiles = new Set(__pagesClientAssets.clientBuildFiles ?? []);
|
|
442
455
|
const _pageRouteTrie = _buildRouteTrie(pageRoutes);
|
|
443
456
|
const _errorPageRoute = {
|
|
444
457
|
pattern: "/_error",
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import { INTERNAL_HEADERS, NEXTJS_DEPLOYMENT_ID_HEADER, VINEXT_INTERNAL_HEADERS,
|
|
|
19
19
|
import { methodNotAllowedResponse, notFoundStaticAssetResponse } from "./server/http-error-responses.js";
|
|
20
20
|
import { isOpenRedirectShaped, sendRepeatedSlashRedirect } from "./server/open-redirect.js";
|
|
21
21
|
import { canonicalizeRequestUrlPathname, filterInternalHeaders, normalizeTrailingSlash } from "./server/request-pipeline.js";
|
|
22
|
-
import {
|
|
22
|
+
import { proxyExternalRequest } from "./config/config-matchers.js";
|
|
23
23
|
import { omitUnusedBuildSourcemap } from "./plugins/transform-result.js";
|
|
24
24
|
import { assetPrefixPathname, isNextStaticPath, resolveAssetsDir } from "./utils/asset-prefix.js";
|
|
25
25
|
import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
|
|
@@ -31,7 +31,7 @@ import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./rout
|
|
|
31
31
|
import { resolveRuntimeEntryModule } from "./entries/runtime-entry-module.js";
|
|
32
32
|
import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
|
|
33
33
|
import { validateMiddlewareMatcherPatterns } from "./server/middleware-matcher-pattern.js";
|
|
34
|
-
import { resolvePagesI18nRequest, shouldRestoreLocaleRootTrailingSlash
|
|
34
|
+
import { resolvePagesI18nRequest, shouldRestoreLocaleRootTrailingSlash } from "./server/pages-i18n.js";
|
|
35
35
|
import { encodeUrlParserIgnoredCharacters, isNextDataPathname, normalizeNextDataPagePathname, parseNextDataPathname, shouldAddTrailingSlashToPagesDataPath, urlParserCreatesPagesDataPath } from "./server/pages-data-route.js";
|
|
36
36
|
import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
|
|
37
37
|
import { findMiddlewareFile, isProxyFile, runMiddleware } from "./server/middleware.js";
|
|
@@ -78,6 +78,7 @@ import { readTrustedRevalidationHostname } from "./server/revalidation-host.js";
|
|
|
78
78
|
import { sealForwardedMiddlewareContext } from "./server/forwarded-middleware-context.js";
|
|
79
79
|
import { installDevStackSourcemapMiddleware } from "./server/dev-stack-sourcemap.js";
|
|
80
80
|
import { traceFrameworkRequest } from "./server/request-tracing.js";
|
|
81
|
+
import { publicFileRouteKey } from "./utils/public-file-path.js";
|
|
81
82
|
import { runPagesRequest } from "./server/pages-request-pipeline.js";
|
|
82
83
|
import { pagesRouteHasPriorityOverAppRoute, validateHybridRouteConflicts } from "./server/hybrid-route-priority.js";
|
|
83
84
|
import { hasReactCompilerPlugin, isReactCompilerPlugin, isReactCompilerRequested, reactCompilerUnsupportedMessage } from "./utils/react-compiler-support.js";
|
|
@@ -134,7 +135,6 @@ import { createExtensionlessDynamicImportPlugin } from "./plugins/extensionless-
|
|
|
134
135
|
import { createWasmModuleImportPlugin } from "./plugins/wasm-module-import.js";
|
|
135
136
|
import { consumerEnvironmentConditionFilter, getTypeofWindowReplacement, mayFoldChangeScannedImports, replaceConsumerEnvironmentConditions } from "./plugins/typeof-window.js";
|
|
136
137
|
import { hasMdxFiles, loadMdxEsmReader, pageExtensionsIncludeMdx } from "./utils/mdx-scan.js";
|
|
137
|
-
import { publicFileRouteKey } from "./utils/public-file-path.js";
|
|
138
138
|
import { scanPublicFileRoutes, scanPublicFiles } from "./utils/public-routes.js";
|
|
139
139
|
import { createIgnoreDynamicRequestsPlugin } from "./plugins/ignore-dynamic-requests.js";
|
|
140
140
|
import { assertPluginRscVersion, needsAppReactServerDom } from "./utils/plugin-rsc-version.js";
|
|
@@ -844,6 +844,7 @@ const PAGES_REQUEST_STAGE_ENTRY = resolveRuntimeEntryModule("pages-request-stage
|
|
|
844
844
|
const PAGES_RESPONSE_STAGE_ENTRY = resolveRuntimeEntryModule("pages-response-stage-entry");
|
|
845
845
|
const NITRO_PUBLIC_FILES_ENTRY = resolveRuntimeEntryModule("nitro-public-files");
|
|
846
846
|
const NITRO_PUBLIC_FILES_PLUGIN = resolveRuntimeEntryModule("nitro-public-files-plugin");
|
|
847
|
+
const SRVX_MIDDLEWARE_ORIGIN_ENTRY = resolveRuntimeEntryModule("srvx-middleware-origin");
|
|
847
848
|
const WORKER_ROUTER_ENTRIES = /* @__PURE__ */ new Set([resolveRuntimeEntryModule("app-router-entry"), resolveRuntimeEntryModule("pages-router-entry")]);
|
|
848
849
|
/** Virtual module that registers config-driven cache adapters (see VinextOptions.cache). */
|
|
849
850
|
const RESOLVED_CACHE_ADAPTERS = "\0" + VIRTUAL_CACHE_ADAPTERS;
|
|
@@ -2359,9 +2360,14 @@ function vinext(options = {}) {
|
|
|
2359
2360
|
const entry = hasAppDir ? "vinext/server/app-router-entry" : "vinext/server/pages-router-entry";
|
|
2360
2361
|
if (!hasAppDir && hasNitroPlugin) return [
|
|
2361
2362
|
`import pagesWorker from ${JSON.stringify(entry)};`,
|
|
2363
|
+
`import { resolveSrvxMiddlewareOrigin } from ${JSON.stringify(SRVX_MIDDLEWARE_ORIGIN_ENTRY)};`,
|
|
2362
2364
|
...nitroPublicFiles ? [`import { withNitroPagesPublicFiles } from ${JSON.stringify(NITRO_PUBLIC_FILES_ENTRY)};`, "const worker = withNitroPagesPublicFiles(pagesWorker);"] : ["const worker = pagesWorker;"],
|
|
2363
2365
|
"export default { fetch(request, env, ctx) {",
|
|
2364
|
-
|
|
2366
|
+
" return worker.fetch(request, env, {",
|
|
2367
|
+
" ...ctx,",
|
|
2368
|
+
` hostRuntime: ${JSON.stringify(nitroHostRuntime)},`,
|
|
2369
|
+
" middlewareOrigin: resolveSrvxMiddlewareOrigin(request),",
|
|
2370
|
+
" });",
|
|
2365
2371
|
"} };"
|
|
2366
2372
|
].join("\n");
|
|
2367
2373
|
return `export { default } from ${JSON.stringify(entry)};`;
|
|
@@ -2453,7 +2459,9 @@ function vinext(options = {}) {
|
|
|
2453
2459
|
dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,
|
|
2454
2460
|
dangerouslyAllowLocalIP: nextConfig?.images?.dangerouslyAllowLocalIP,
|
|
2455
2461
|
contentDispositionType: nextConfig?.images?.contentDispositionType,
|
|
2456
|
-
contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy
|
|
2462
|
+
contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy,
|
|
2463
|
+
minimumCacheTTL: nextConfig?.images?.minimumCacheTTL,
|
|
2464
|
+
maximumResponseBody: nextConfig?.images?.maximumResponseBody
|
|
2457
2465
|
},
|
|
2458
2466
|
hasPagesDir,
|
|
2459
2467
|
publicFiles: isServeCommand && devPublicFileRoutes ? [...devPublicFileRoutes].sort() : scanPublicFileRoutes(root, this.environment.config.publicDir === "" ? false : this.environment.config.publicDir),
|
|
@@ -2734,9 +2742,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2734
2742
|
handler(_options, bundle) {
|
|
2735
2743
|
if (this.environment?.name !== "client") return;
|
|
2736
2744
|
const manifest = {};
|
|
2745
|
+
const appBrowserRuntimeModule = toSlash(resolveRuntimeEntryModule("app-browser-entry"));
|
|
2737
2746
|
for (const chunk of Object.values(bundle)) {
|
|
2738
2747
|
if (chunk.type !== "chunk") continue;
|
|
2739
2748
|
if (chunk.isDynamicEntry && isVirtualEntryFacade(chunk.facadeModuleId, VIRTUAL_APP_ROUTE_MANIFEST)) manifest.appRouteManifest = chunk.fileName;
|
|
2749
|
+
if (chunk.moduleIds.some((id) => toSlash(id) === appBrowserRuntimeModule)) manifest.appBrowserRuntime = chunk.fileName;
|
|
2740
2750
|
if (!chunk.isEntry) continue;
|
|
2741
2751
|
if (isVirtualEntryFacade(chunk.facadeModuleId, VIRTUAL_CLIENT_ENTRY)) manifest.pagesClientEntry = chunk.fileName;
|
|
2742
2752
|
else if (isVirtualEntryFacade(chunk.facadeModuleId, VIRTUAL_APP_BROWSER_ENTRY)) manifest.appBrowserEntry = chunk.fileName;
|
|
@@ -3441,25 +3451,6 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3441
3451
|
});
|
|
3442
3452
|
}
|
|
3443
3453
|
}
|
|
3444
|
-
const filePathMatchesRewrite = [
|
|
3445
|
-
...nextConfig?.rewrites.beforeFiles ?? [],
|
|
3446
|
-
...nextConfig?.rewrites.afterFiles ?? [],
|
|
3447
|
-
...nextConfig?.rewrites.fallback ?? []
|
|
3448
|
-
].some((rewrite) => matchesRewriteSource(pathname, rewrite, {
|
|
3449
|
-
basePath: bp,
|
|
3450
|
-
hadBasePath: true
|
|
3451
|
-
}));
|
|
3452
|
-
const isFilePathRequest = pathname.includes(".") && !pathname.endsWith(".html");
|
|
3453
|
-
const isExistingPublicMutation = req.method !== "GET" && req.method !== "HEAD" && isExistingDevPublicFile(pathname);
|
|
3454
|
-
let filePathMatchesPagesRoute = false;
|
|
3455
|
-
const requestHostname = getUrlHostname(requestOrigin);
|
|
3456
|
-
if (isFilePathRequest && !filePathMatchesRewrite && !isDataReq) {
|
|
3457
|
-
const [pageRoutes, apiRoutes] = await Promise.all([pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher), apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher)]);
|
|
3458
|
-
const pageRouteUrl = nextConfig?.i18n ? resolvePagesI18nRequest(pathname, nextConfig.i18n, req.headers, requestHostname, bp, nextConfig.trailingSlash ?? false).url : pathname;
|
|
3459
|
-
const apiRouteUrl = stripI18nLocaleForApiRoute(pathname, nextConfig?.i18n ?? null);
|
|
3460
|
-
filePathMatchesPagesRoute = matchRoute(pageRouteUrl, pageRoutes) !== null || matchRoute(apiRouteUrl, apiRoutes) !== null;
|
|
3461
|
-
}
|
|
3462
|
-
if (isFilePathRequest && !isDataReq && !filePathMatchesRewrite && !filePathMatchesPagesRoute && !isNextStaticPath(pathname, "", assetPrefixPathname(nextConfig?.assetPrefix ?? "")) && !isExistingPublicMutation) return next();
|
|
3463
3454
|
const rawHeaders = new Headers(Object.fromEntries(Object.entries(req.headers).filter(([k, v]) => v !== void 0 && !k.startsWith(":")).map(([k, v]) => [k, Array.isArray(v) ? v.join(", ") : String(v)])));
|
|
3464
3455
|
const isDataRequest = isDataReq;
|
|
3465
3456
|
const nodeRequestHeaders = filterInternalHeaders(rawHeaders);
|
|
@@ -3489,7 +3480,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3489
3480
|
headers: nodeRequestHeaders,
|
|
3490
3481
|
signal: webRequest.signal
|
|
3491
3482
|
});
|
|
3492
|
-
const result = await runMiddleware(getPagesRunner(), capturedMiddlewarePath, middlewareRequest, nextConfig?.i18n, nextConfig?.basePath, nextConfig?.trailingSlash, opts.isDataRequest, pathname, opts.isStaleDataRequest, nextConfig?.skipTrailingSlashRedirect);
|
|
3483
|
+
const result = await runMiddleware(getPagesRunner(), capturedMiddlewarePath, middlewareRequest, nextConfig?.i18n, nextConfig?.basePath, nextConfig?.trailingSlash, opts.isDataRequest, pathname, opts.isStaleDataRequest, nextConfig?.skipTrailingSlashRedirect, opts.restoreLocaleRootTrailingSlash);
|
|
3493
3484
|
if (hasAppDir && result.continue) {
|
|
3494
3485
|
const mwCtxEntries = [];
|
|
3495
3486
|
if (result.responseHeaders) {
|
|
@@ -4120,6 +4111,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
4120
4111
|
nitroHostRuntime = nitro.options.exportConditions?.includes("workerd") ? "worker" : "node";
|
|
4121
4112
|
if (!nextConfig) return;
|
|
4122
4113
|
if (!hasAppDir && !hasPagesDir) return;
|
|
4114
|
+
if (!nitro.options.dev) {
|
|
4115
|
+
const requestTargetPlugin = resolveRuntimeEntryModule("nitro-request-target-plugin");
|
|
4116
|
+
nitro.options.plugins ??= [];
|
|
4117
|
+
if (!nitro.options.plugins.includes(requestTargetPlugin)) nitro.options.plugins.push(requestTargetPlugin);
|
|
4118
|
+
}
|
|
4123
4119
|
nitroPublicFiles = registerNitroPublicFiles(nitro.options, NITRO_PUBLIC_FILES_PLUGIN, () => scanPublicFiles(root, nitroPublicDir));
|
|
4124
4120
|
if (resolvedServerExternalPackages.length > 0) nitro.options.traceDeps = [.../* @__PURE__ */ new Set([...nitro.options.traceDeps ?? [], ...resolvedServerExternalPackages])];
|
|
4125
4121
|
} }
|
|
@@ -4266,6 +4262,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
4266
4262
|
pagesClientAssetsModule = buildPagesClientAssetsModule({
|
|
4267
4263
|
clientEntry: runtimeMetadata.clientEntryFile ?? void 0,
|
|
4268
4264
|
appBootstrapPreinitModules: runtimeMetadata.appBootstrapPreinitModules,
|
|
4265
|
+
appBootstrapPreloadModules: runtimeMetadata.appBootstrapPreloadModules,
|
|
4269
4266
|
appRouteManifestModule: runtimeMetadata.appRouteManifestModule,
|
|
4270
4267
|
appClientReferenceChunks: runtimeMetadata.appClientReferenceChunks,
|
|
4271
4268
|
ssrManifest,
|
package/dist/init-platform.js
CHANGED
|
@@ -148,9 +148,9 @@ async function resolveInitOptions(args, options = {}) {
|
|
|
148
148
|
if (name && platform !== "cloudflare") throw new Error("--name requires --platform=cloudflare.");
|
|
149
149
|
const explicitPrerender = parsePrerenderArg(args);
|
|
150
150
|
if (platform === "cloudflare" && platformOptions?.cdnCache === "static-assets" && explicitPrerender === false) throw new Error("--no-prerender cannot be used with --cdn-cache=static-assets, which requires build-time prerendering.");
|
|
151
|
-
const supportsWarmCdnCache = platformOptions?.cdnCache
|
|
151
|
+
const supportsWarmCdnCache = platformOptions?.cdnCache !== void 0 && platformOptions.cdnCache !== "none";
|
|
152
152
|
if (platform === "cloudflare" && !supportsWarmCdnCache) {
|
|
153
|
-
if (explicitWarmCdnCache === true) throw new Error("--warm-cache requires --cdn-cache=response-store or
|
|
153
|
+
if (explicitWarmCdnCache === true) throw new Error("--warm-cache requires a cache: pass --cdn-cache=response-store, workers-cache, data-cache, or static-assets.");
|
|
154
154
|
}
|
|
155
155
|
const prerender = platform === "cloudflare" && platformOptions?.cdnCache === "static-assets" ? false : explicitPrerender ?? await resolveInitPrerender(args, options, platform);
|
|
156
156
|
const warmCdnCache = platform === "cloudflare" && supportsWarmCdnCache ? await resolveInitWarmCdnCache(args, options) : false;
|