@opennextjs/aws 4.1.7 → 4.1.9
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/adapters/cache.d.ts +1 -1
- package/dist/adapters/cache.js +7 -6
- package/dist/adapters/composable-cache.d.ts +1 -1
- package/dist/adapters/composable-cache.js +2 -2
- package/dist/adapters/config/util.d.ts +10 -10
- package/dist/adapters/edge-adapter.js +2 -2
- package/dist/adapters/middleware.js +2 -2
- package/dist/build/copyTracedFiles.js +6 -2
- package/dist/build/edge/createEdgeBundle.d.ts +2 -2
- package/dist/build/installDeps.d.ts +1 -1
- package/dist/build/patch/patches/patchBackgroundRevalidation.d.ts +2 -1
- package/dist/build/patch/patches/patchBackgroundRevalidation.js +26 -7
- package/dist/build/validateConfig.d.ts +1 -1
- package/dist/core/createGenericHandler.d.ts +2 -2
- package/dist/core/edgeFunctionHandler.d.ts +1 -1
- package/dist/core/nodeMiddlewareHandler.d.ts +1 -1
- package/dist/core/requestHandler.d.ts +2 -2
- package/dist/core/requestHandler.js +15 -7
- package/dist/core/resolve.d.ts +10 -10
- package/dist/core/routing/cacheInterceptor.d.ts +1 -1
- package/dist/core/routing/cacheInterceptor.js +6 -6
- package/dist/core/routing/i18n/index.d.ts +2 -2
- package/dist/core/routing/matcher.d.ts +61 -6
- package/dist/core/routing/matcher.js +283 -55
- package/dist/core/routing/routeMatcher.d.ts +1 -1
- package/dist/core/routing/routeMatcher.js +1 -1
- package/dist/core/routing/util.d.ts +20 -4
- package/dist/core/routing/util.js +32 -15
- package/dist/core/routingHandler.d.ts +2 -2
- package/dist/core/routingHandler.js +3 -3
- package/dist/helpers/withCloudflare.d.ts +1 -1
- package/dist/helpers/withSST.d.ts +2 -2
- package/dist/http/openNextResponse.d.ts +1 -1
- package/dist/overrides/assetResolver/dummy.d.ts +1 -1
- package/dist/overrides/converters/aws-apigw-v1.d.ts +1 -1
- package/dist/overrides/converters/aws-apigw-v1.js +1 -1
- package/dist/overrides/converters/aws-apigw-v2.d.ts +1 -1
- package/dist/overrides/converters/aws-apigw-v2.js +2 -2
- package/dist/overrides/converters/aws-cloudfront.d.ts +1 -1
- package/dist/overrides/converters/aws-cloudfront.js +2 -2
- package/dist/overrides/converters/dummy.d.ts +1 -1
- package/dist/overrides/converters/edge.d.ts +2 -2
- package/dist/overrides/converters/edge.js +1 -1
- package/dist/overrides/converters/node.d.ts +1 -1
- package/dist/overrides/converters/sqs-revalidate.d.ts +1 -1
- package/dist/overrides/imageLoader/dummy.d.ts +1 -1
- package/dist/overrides/imageLoader/dummy.js +1 -1
- package/dist/overrides/imageLoader/fs-dev.js +2 -2
- package/dist/overrides/imageLoader/host.d.ts +1 -1
- package/dist/overrides/imageLoader/host.js +1 -1
- package/dist/overrides/imageLoader/s3-lite.d.ts +1 -1
- package/dist/overrides/imageLoader/s3-lite.js +1 -1
- package/dist/overrides/imageLoader/s3.d.ts +1 -1
- package/dist/overrides/imageLoader/s3.js +1 -1
- package/dist/overrides/incrementalCache/dummy.d.ts +1 -1
- package/dist/overrides/incrementalCache/dummy.js +1 -1
- package/dist/overrides/incrementalCache/fs-dev.js +1 -1
- package/dist/overrides/incrementalCache/multi-tier-ddb-s3.d.ts +1 -1
- package/dist/overrides/incrementalCache/multi-tier-ddb-s3.js +2 -2
- package/dist/overrides/incrementalCache/s3-lite.d.ts +1 -1
- package/dist/overrides/incrementalCache/s3-lite.js +2 -2
- package/dist/overrides/incrementalCache/s3.d.ts +1 -1
- package/dist/overrides/originResolver/dummy.d.ts +1 -1
- package/dist/overrides/originResolver/pattern-env.d.ts +1 -1
- package/dist/overrides/proxyExternalRequest/dummy.d.ts +1 -1
- package/dist/overrides/proxyExternalRequest/dummy.js +1 -1
- package/dist/overrides/proxyExternalRequest/fetch.d.ts +1 -1
- package/dist/overrides/proxyExternalRequest/fetch.js +1 -1
- package/dist/overrides/proxyExternalRequest/node.d.ts +1 -1
- package/dist/overrides/queue/dummy.d.ts +1 -1
- package/dist/overrides/queue/dummy.js +1 -1
- package/dist/overrides/queue/sqs-lite.d.ts +1 -1
- package/dist/overrides/queue/sqs-lite.js +2 -2
- package/dist/overrides/queue/sqs.d.ts +1 -1
- package/dist/overrides/tagCache/dummy.d.ts +1 -1
- package/dist/overrides/tagCache/dynamodb-lite.d.ts +1 -1
- package/dist/overrides/tagCache/dynamodb-lite.js +2 -2
- package/dist/overrides/tagCache/dynamodb-nextMode.d.ts +1 -1
- package/dist/overrides/tagCache/dynamodb-nextMode.js +2 -2
- package/dist/overrides/tagCache/dynamodb.d.ts +1 -1
- package/dist/overrides/tagCache/fs-dev-nextMode.d.ts +1 -1
- package/dist/overrides/tagCache/fs-dev.d.ts +1 -1
- package/dist/overrides/tagCache/fs-dev.js +1 -1
- package/dist/overrides/warmer/aws-lambda.d.ts +1 -1
- package/dist/overrides/warmer/dummy.d.ts +1 -1
- package/dist/overrides/warmer/dummy.js +1 -1
- package/dist/overrides/wrappers/aws-apigw-streaming.d.ts +1 -1
- package/dist/overrides/wrappers/aws-lambda-compressed.d.ts +1 -1
- package/dist/overrides/wrappers/aws-lambda-streaming.d.ts +1 -1
- package/dist/overrides/wrappers/aws-lambda.d.ts +1 -1
- package/dist/overrides/wrappers/cloudflare-edge.d.ts +2 -2
- package/dist/overrides/wrappers/cloudflare-node.d.ts +2 -2
- package/dist/overrides/wrappers/dummy.d.ts +1 -1
- package/dist/overrides/wrappers/express-dev.js +2 -2
- package/dist/overrides/wrappers/node.d.ts +1 -1
- package/dist/plugins/resolve.d.ts +2 -2
- package/dist/types/global.d.ts +1 -1
- package/dist/types/overrides.d.ts +1 -1
- package/dist/utils/cache.d.ts +1 -1
- package/dist/utils/promise.d.ts +18 -1
- package/dist/utils/promise.js +27 -9
- package/package.json +12 -12
package/dist/adapters/cache.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CacheHandlerValue, IncrementalCacheContext, IncrementalCacheValue } from "../types/cache";
|
|
1
|
+
import type { CacheHandlerValue, IncrementalCacheContext, IncrementalCacheValue } from "../types/cache.js";
|
|
2
2
|
export declare const SOFT_TAG_PREFIX = "_N_T_/";
|
|
3
3
|
export default class Cache {
|
|
4
4
|
get(key: string, options?: boolean | {
|
package/dist/adapters/cache.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getStaleLastModified, getTagsFromValue, hasBeenRevalidated, isStale, writeTags, } from "../utils/cache";
|
|
1
|
+
import { getStaleLastModified, getTagsFromValue, hasBeenRevalidated, isStale, writeTags, } from "../utils/cache.js";
|
|
2
2
|
import { isBinaryContentType } from "../utils/binary";
|
|
3
3
|
import { CACHE_TAGS_HEADER } from "../utils/cacheHeaders";
|
|
4
4
|
import { getPathFromRouteCacheKey } from "../utils/routeCacheKey";
|
|
@@ -198,14 +198,15 @@ export default class Cache {
|
|
|
198
198
|
}
|
|
199
199
|
const store = globalThis.__openNextAls.getStore();
|
|
200
200
|
const writePromise = this.writeCache(key, data, ctx);
|
|
201
|
-
// Next.js ignores
|
|
202
|
-
//
|
|
203
|
-
//
|
|
201
|
+
// Next.js ignores some cache handler results and does not reliably retain
|
|
202
|
+
// FETCH writes created during a Server Action Flight render. Register every
|
|
203
|
+
// write with the request runner before preserving FETCH's awaited behavior.
|
|
204
|
+
if (store !== undefined) {
|
|
205
|
+
store.pendingPromiseRunner.add(writePromise);
|
|
206
|
+
}
|
|
204
207
|
if (data?.kind === "FETCH" || store === undefined) {
|
|
205
208
|
await writePromise;
|
|
206
|
-
return;
|
|
207
209
|
}
|
|
208
|
-
store.pendingPromiseRunner.add(writePromise);
|
|
209
210
|
}
|
|
210
211
|
async writeCache(key, data, ctx) {
|
|
211
212
|
try {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isStale, writeTags } from "../utils/cache";
|
|
2
|
-
import { fromReadableStream, toReadableStream } from "../utils/stream";
|
|
1
|
+
import { isStale, writeTags } from "../utils/cache.js";
|
|
2
|
+
import { fromReadableStream, toReadableStream } from "../utils/stream.js";
|
|
3
3
|
import { debug } from "./logger";
|
|
4
4
|
/**
|
|
5
5
|
* In-flight writes are tracked per request, not per module.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FunctionsConfigManifest, MiddlewareManifest, NextConfig, PrerenderManifest } from "../../types/next-types";
|
|
1
|
+
import type { FunctionsConfigManifest, MiddlewareManifest, NextConfig, PrerenderManifest } from "../../types/next-types.js";
|
|
2
2
|
import type { PublicFiles } from "../../build";
|
|
3
3
|
export declare function loadConfig(nextDir: string): NextConfig;
|
|
4
4
|
export declare function loadBuildId(nextDir: string): string;
|
|
@@ -8,22 +8,22 @@ export declare function loadPublicAssets(openNextDir: string): PublicFiles;
|
|
|
8
8
|
export declare function loadRoutesManifest(nextDir: string): {
|
|
9
9
|
basePath: string | undefined;
|
|
10
10
|
rewrites: {
|
|
11
|
-
beforeFiles: import("../../types/next-types").RewriteDefinition[];
|
|
12
|
-
afterFiles: import("../../types/next-types").RewriteDefinition[];
|
|
13
|
-
fallback: import("../../types/next-types").RewriteDefinition[];
|
|
11
|
+
beforeFiles: import("../../types/next-types.js").RewriteDefinition[];
|
|
12
|
+
afterFiles: import("../../types/next-types.js").RewriteDefinition[];
|
|
13
|
+
fallback: import("../../types/next-types.js").RewriteDefinition[];
|
|
14
14
|
};
|
|
15
|
-
redirects: import("../../types/next-types").RedirectDefinition[];
|
|
15
|
+
redirects: import("../../types/next-types.js").RedirectDefinition[];
|
|
16
16
|
routes: {
|
|
17
|
-
static: import("../../types/next-types").RouteDefinition[];
|
|
18
|
-
dynamic: import("../../types/next-types").RouteDefinition[];
|
|
17
|
+
static: import("../../types/next-types.js").RouteDefinition[];
|
|
18
|
+
dynamic: import("../../types/next-types.js").RouteDefinition[];
|
|
19
19
|
data: {
|
|
20
|
-
static: import("../../types/next-types").DataRouteDefinition[];
|
|
21
|
-
dynamic: import("../../types/next-types").DataRouteDefinition[];
|
|
20
|
+
static: import("../../types/next-types.js").DataRouteDefinition[];
|
|
21
|
+
dynamic: import("../../types/next-types.js").DataRouteDefinition[];
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
locales: string[];
|
|
25
25
|
};
|
|
26
|
-
export declare function loadConfigHeaders(nextDir: string): import("../../types/next-types").Header[] | undefined;
|
|
26
|
+
export declare function loadConfigHeaders(nextDir: string): import("../../types/next-types.js").Header[] | undefined;
|
|
27
27
|
export declare function loadPrerenderManifest(nextDir: string): PrerenderManifest | undefined;
|
|
28
28
|
export declare function loadAppPathsManifest(nextDir: string): Record<string, string>;
|
|
29
29
|
export declare function loadAppPathRoutesManifest(nextDir: string): Record<string, string>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { runWithOpenNextRequestContext } from "../utils/promise";
|
|
2
|
-
import { emptyReadableStream } from "../utils/stream";
|
|
1
|
+
import { runWithOpenNextRequestContext } from "../utils/promise.js";
|
|
2
|
+
import { emptyReadableStream } from "../utils/stream.js";
|
|
3
3
|
// We import it like that so that the edge plugin can replace it
|
|
4
4
|
import { NextConfig } from "../adapters/config";
|
|
5
5
|
import { createGenericHandler } from "../core/createGenericHandler";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ISR_HEADER } from "../utils/cacheHeaders";
|
|
2
|
-
import { runWithOpenNextRequestContext } from "../utils/promise";
|
|
1
|
+
import { ISR_HEADER } from "../utils/cacheHeaders.js";
|
|
2
|
+
import { runWithOpenNextRequestContext } from "../utils/promise.js";
|
|
3
3
|
import { debug, error } from "../adapters/logger";
|
|
4
4
|
import { createGenericHandler } from "../core/createGenericHandler";
|
|
5
5
|
import { resolveAssetResolver, resolveIncrementalCache, resolveOriginResolver, resolveProxyRequest, resolveQueue, resolveTagCache, } from "../core/resolve";
|
|
@@ -319,8 +319,12 @@ File ${serverPath} does not exist
|
|
|
319
319
|
}
|
|
320
320
|
// Copy .next/static/css from standalone to output dir
|
|
321
321
|
// needed for optimizeCss feature to work
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
// The directory is not emitted when all the css is inlined
|
|
323
|
+
const standaloneCssDir = path.join(standaloneNextDir, "static", "css");
|
|
324
|
+
if (config.experimental.optimizeCss && existsSync(standaloneCssDir)) {
|
|
325
|
+
cpSync(standaloneCssDir, path.join(outputNextDir, "static", "css"), {
|
|
326
|
+
recursive: true,
|
|
327
|
+
});
|
|
324
328
|
}
|
|
325
329
|
logger.debug("copyTracedFiles:", Date.now() - tsStart, "ms");
|
|
326
330
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Plugin } from "esbuild";
|
|
2
|
-
import type { MiddlewareInfo } from "../../types/next-types";
|
|
3
|
-
import type { IncludedConverter, IncludedOriginResolver, LazyLoadedOverride, OverrideOptions, SplittedFunctionOptions } from "../../types/open-next";
|
|
2
|
+
import type { MiddlewareInfo } from "../../types/next-types.js";
|
|
3
|
+
import type { IncludedConverter, IncludedOriginResolver, LazyLoadedOverride, OverrideOptions, SplittedFunctionOptions } from "../../types/open-next.js";
|
|
4
4
|
import type { OriginResolver } from "../../types/overrides.js";
|
|
5
5
|
import { ContentUpdater } from "../../plugins/content-updater.js";
|
|
6
6
|
import { type BuildOptions } from "../helper.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { InstallOptions } from "../types/open-next";
|
|
1
|
+
import type { InstallOptions } from "../types/open-next.js";
|
|
2
2
|
export declare function installDependencies(outputDir: string, installOptions?: InstallOptions): void;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export declare const rule = "\nrule:\n kind: binary_expression\n all:\n - has:\n kind:
|
|
1
|
+
export declare const rule = "\nrule:\n kind: binary_expression\n # The names are mangled in the minified runtimes\n pattern: \"!$ENTRY.isStale || $CONTEXT.isPrefetch\"\n all:\n # It has to be the whole check, not a part of a bigger expression\n - not:\n inside:\n kind: binary_expression\n # It has to be guarded by the on-demand revalidation check\n - inside:\n kind: if_statement\n stopBy: end\n has:\n field: condition\n stopBy: end\n any:\n # Next 15.5+ and its minified runtime copies use the same context object\n - pattern: \"!$CONTEXT.isOnDemandRevalidate\"\n # Earlier unminified versions keep this flag in a local\n - pattern: \"!isOnDemandRevalidate\"\nfix:\n 'true'";
|
|
2
2
|
export declare const patchBackgroundRevalidation: {
|
|
3
3
|
name: string;
|
|
4
4
|
patches: {
|
|
5
5
|
versions: ">=14.1.0";
|
|
6
6
|
pathFilter: RegExp;
|
|
7
|
+
contentFilter: RegExp;
|
|
7
8
|
patchCode: import("../codePatcher.js").PatchCodeFn;
|
|
8
9
|
}[];
|
|
9
10
|
};
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import { getCrossPlatformPathRegex } from "../../../utils/regex.js";
|
|
2
2
|
import { createPatchCode } from "../astCodePatcher.js";
|
|
3
|
+
// Matches the check that decides whether a cached entry can be served as is in `ResponseCache.get`:
|
|
4
|
+
// if (entry && !context.isOnDemandRevalidate) { ...; if (!entry.isStale || context.isPrefetch) return ... }
|
|
5
|
+
// which is minified in the compiled runtimes as:
|
|
6
|
+
// if ((a = ...) && !r.isOnDemandRevalidate && (n(a), i = !0, !a.isStale || r.isPrefetch)) return a;
|
|
3
7
|
export const rule = `
|
|
4
8
|
rule:
|
|
5
9
|
kind: binary_expression
|
|
10
|
+
# The names are mangled in the minified runtimes
|
|
11
|
+
pattern: "!$ENTRY.isStale || $CONTEXT.isPrefetch"
|
|
6
12
|
all:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
# It has to be the whole check, not a part of a bigger expression
|
|
14
|
+
- not:
|
|
15
|
+
inside:
|
|
16
|
+
kind: binary_expression
|
|
17
|
+
# It has to be guarded by the on-demand revalidation check
|
|
18
|
+
- inside:
|
|
19
|
+
kind: if_statement
|
|
20
|
+
stopBy: end
|
|
21
|
+
has:
|
|
22
|
+
field: condition
|
|
23
|
+
stopBy: end
|
|
24
|
+
any:
|
|
25
|
+
# Next 15.5+ and its minified runtime copies use the same context object
|
|
26
|
+
- pattern: "!$CONTEXT.isOnDemandRevalidate"
|
|
27
|
+
# Earlier unminified versions keep this flag in a local
|
|
28
|
+
- pattern: "!isOnDemandRevalidate"
|
|
13
29
|
fix:
|
|
14
30
|
'true'`;
|
|
15
31
|
export const patchBackgroundRevalidation = {
|
|
@@ -18,7 +34,10 @@ export const patchBackgroundRevalidation = {
|
|
|
18
34
|
{
|
|
19
35
|
// TODO: test for earlier versions of Next
|
|
20
36
|
versions: ">=14.1.0",
|
|
21
|
-
|
|
37
|
+
// Since Next 15.5 route modules use their own `ResponseCache`, which is inlined (and minified)
|
|
38
|
+
// in `next/dist/compiled/next-server/*.runtime.prod.js`
|
|
39
|
+
pathFilter: getCrossPlatformPathRegex(String.raw `(server/response-cache/index\.js|\.runtime\.prod\.js)$`, { escape: false }),
|
|
40
|
+
contentFilter: /\.isStale\s*\|\|\s*[\w$]+\.isPrefetch/,
|
|
22
41
|
patchCode: createPatchCode(rule),
|
|
23
42
|
},
|
|
24
43
|
],
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { OpenNextConfig } from "../types/open-next";
|
|
1
|
+
import type { OpenNextConfig } from "../types/open-next.js";
|
|
2
2
|
export declare function validateConfig(config: OpenNextConfig): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BaseEventOrResult, InternalEvent, InternalResult } from "../types/open-next";
|
|
2
|
-
import type { OpenNextHandler } from "../types/overrides";
|
|
1
|
+
import type { BaseEventOrResult, InternalEvent, InternalResult } from "../types/open-next.js";
|
|
2
|
+
import type { OpenNextHandler } from "../types/overrides.js";
|
|
3
3
|
type HandlerType = "imageOptimization" | "revalidate" | "warmer" | "middleware" | "initializationFunction";
|
|
4
4
|
type GenericHandler<Type extends HandlerType, E extends BaseEventOrResult = InternalEvent, R extends BaseEventOrResult = InternalResult> = {
|
|
5
5
|
handler: OpenNextHandler<E, R>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { InternalEvent, InternalResult } from "../types/open-next";
|
|
2
|
-
import type { OpenNextHandlerOptions } from "../types/overrides";
|
|
1
|
+
import type { InternalEvent, InternalResult } from "../types/open-next.js";
|
|
2
|
+
import type { OpenNextHandlerOptions } from "../types/overrides.js";
|
|
3
3
|
export declare function openNextHandler(internalEvent: InternalEvent, options?: OpenNextHandlerOptions): Promise<InternalResult>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { IncomingMessage } from "../http/index.js";
|
|
3
|
-
import { ISR_HEADER } from "../utils/cacheHeaders";
|
|
4
|
-
import { runWithOpenNextRequestContext } from "../utils/promise";
|
|
5
|
-
import { NextConfig } from "../adapters/config/index";
|
|
3
|
+
import { ISR_HEADER } from "../utils/cacheHeaders.js";
|
|
4
|
+
import { runWithOpenNextRequestContext } from "../utils/promise.js";
|
|
5
|
+
import { NextConfig } from "../adapters/config/index.js";
|
|
6
6
|
import { debug, error } from "../adapters/logger";
|
|
7
7
|
import { patchAsyncStorage } from "./patchAsyncStorage";
|
|
8
|
-
import { constructNextUrl, convertRes, convertToQuery,
|
|
8
|
+
import { constructNextUrl, convertRes, convertToQuery, createServerResponse, } from "./routing/util";
|
|
9
9
|
import routingHandler, { INTERNAL_EVENT_REQUEST_ID, INTERNAL_HEADER_REWRITE_STATUS_CODE, INTERNAL_HEADER_INITIAL_URL, INTERNAL_HEADER_RESOLVED_ROUTES, MIDDLEWARE_HEADER_PREFIX, MIDDLEWARE_HEADER_PREFIX_LEN, } from "./routingHandler";
|
|
10
10
|
import { requestHandler, setNextjsPrebundledReact } from "./util";
|
|
11
11
|
// This is used to identify requests in the cache
|
|
@@ -161,6 +161,14 @@ export async function openNextHandler(internalEvent, options) {
|
|
|
161
161
|
return internalResult;
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Applies routing metadata and invokes the Next.js request handler.
|
|
166
|
+
*
|
|
167
|
+
* @param req The request passed to Next.js
|
|
168
|
+
* @param res The response populated by Next.js
|
|
169
|
+
* @param routingResult The resolved OpenNext route and request metadata
|
|
170
|
+
* @return A promise that resolves after Next.js handles the request
|
|
171
|
+
*/
|
|
164
172
|
async function processRequest(req, res, routingResult) {
|
|
165
173
|
// @ts-ignore
|
|
166
174
|
// Next.js doesn't parse body if the property exists
|
|
@@ -202,9 +210,9 @@ async function processRequest(req, res, routingResult) {
|
|
|
202
210
|
// TODO: only enable this on Next 15.4+
|
|
203
211
|
// We need to set the pathname to the data request path
|
|
204
212
|
//#override setInitialURL
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
213
|
+
// `invokeQuery` carries destination query values for server APIs, while
|
|
214
|
+
// `req.url` remains the browser-visible URL used by the App Router state.
|
|
215
|
+
req.url = initialURL.pathname + initialURL.search;
|
|
208
216
|
//#endOverride
|
|
209
217
|
await requestHandler(requestMetadata)(req, res);
|
|
210
218
|
}
|
package/dist/core/resolve.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BaseEventOrResult, DefaultOverrideOptions, ExternalMiddlewareConfig, InternalEvent, InternalResult, OpenNextConfig, OverrideOptions } from "../types/open-next";
|
|
2
|
-
import type { Converter, TagCache, Wrapper } from "../types/overrides";
|
|
1
|
+
import type { BaseEventOrResult, DefaultOverrideOptions, ExternalMiddlewareConfig, InternalEvent, InternalResult, OpenNextConfig, OverrideOptions } from "../types/open-next.js";
|
|
2
|
+
import type { Converter, TagCache, Wrapper } from "../types/overrides.js";
|
|
3
3
|
type RemoveUndefined<T> = T extends undefined ? never : T;
|
|
4
4
|
export declare function resolveConverter<E extends BaseEventOrResult = InternalEvent, R extends BaseEventOrResult = InternalResult>(converter: DefaultOverrideOptions<E, R>["converter"]): Promise<Converter<E, R>>;
|
|
5
5
|
export declare function resolveWrapper<E extends BaseEventOrResult = InternalEvent, R extends BaseEventOrResult = InternalResult>(wrapper: DefaultOverrideOptions<E, R>["wrapper"]): Promise<Wrapper<E, R>>;
|
|
@@ -16,40 +16,40 @@ export declare function resolveTagCache(tagCache: OverrideOptions["tagCache"]):
|
|
|
16
16
|
* @returns
|
|
17
17
|
* @__PURE__
|
|
18
18
|
*/
|
|
19
|
-
export declare function resolveQueue(queue: OverrideOptions["queue"]): Promise<import("../types/overrides").Queue>;
|
|
19
|
+
export declare function resolveQueue(queue: OverrideOptions["queue"]): Promise<import("../types/overrides.js").Queue>;
|
|
20
20
|
/**
|
|
21
21
|
*
|
|
22
22
|
* @param incrementalCache
|
|
23
23
|
* @returns
|
|
24
24
|
* @__PURE__
|
|
25
25
|
*/
|
|
26
|
-
export declare function resolveIncrementalCache(incrementalCache: OverrideOptions["incrementalCache"]): Promise<import("../types/overrides").IncrementalCache>;
|
|
26
|
+
export declare function resolveIncrementalCache(incrementalCache: OverrideOptions["incrementalCache"]): Promise<import("../types/overrides.js").IncrementalCache>;
|
|
27
27
|
/**
|
|
28
28
|
* @param imageLoader
|
|
29
29
|
* @returns
|
|
30
30
|
* @__PURE__
|
|
31
31
|
*/
|
|
32
|
-
export declare function resolveImageLoader(imageLoader: RemoveUndefined<OpenNextConfig["imageOptimization"]>["loader"]): Promise<import("../types/overrides").ImageLoader>;
|
|
32
|
+
export declare function resolveImageLoader(imageLoader: RemoveUndefined<OpenNextConfig["imageOptimization"]>["loader"]): Promise<import("../types/overrides.js").ImageLoader>;
|
|
33
33
|
/**
|
|
34
34
|
* @returns
|
|
35
35
|
* @__PURE__
|
|
36
36
|
*/
|
|
37
|
-
export declare function resolveOriginResolver(originResolver: RemoveUndefined<ExternalMiddlewareConfig>["originResolver"]): Promise<import("../types/overrides").OriginResolver>;
|
|
37
|
+
export declare function resolveOriginResolver(originResolver: RemoveUndefined<ExternalMiddlewareConfig>["originResolver"]): Promise<import("../types/overrides.js").OriginResolver>;
|
|
38
38
|
/**
|
|
39
39
|
* @returns
|
|
40
40
|
* @__PURE__
|
|
41
41
|
*/
|
|
42
|
-
export declare function resolveAssetResolver(assetResolver: RemoveUndefined<OpenNextConfig["middleware"]>["assetResolver"]): Promise<import("../types/overrides").AssetResolver>;
|
|
42
|
+
export declare function resolveAssetResolver(assetResolver: RemoveUndefined<OpenNextConfig["middleware"]>["assetResolver"]): Promise<import("../types/overrides.js").AssetResolver>;
|
|
43
43
|
/**
|
|
44
44
|
* @__PURE__
|
|
45
45
|
*/
|
|
46
|
-
export declare function resolveWarmerInvoke(warmer: RemoveUndefined<OpenNextConfig["warmer"]>["invokeFunction"]): Promise<import("../types/overrides").Warmer>;
|
|
46
|
+
export declare function resolveWarmerInvoke(warmer: RemoveUndefined<OpenNextConfig["warmer"]>["invokeFunction"]): Promise<import("../types/overrides.js").Warmer>;
|
|
47
47
|
/**
|
|
48
48
|
* @__PURE__
|
|
49
49
|
*/
|
|
50
|
-
export declare function resolveProxyRequest(proxyRequest: OverrideOptions["proxyExternalRequest"]): Promise<import("../types/overrides").ProxyExternalRequest>;
|
|
50
|
+
export declare function resolveProxyRequest(proxyRequest: OverrideOptions["proxyExternalRequest"]): Promise<import("../types/overrides.js").ProxyExternalRequest>;
|
|
51
51
|
/**
|
|
52
52
|
* @__PURE__
|
|
53
53
|
*/
|
|
54
|
-
export declare function resolveCdnInvalidation(cdnInvalidation: OverrideOptions["cdnInvalidation"]): Promise<import("../types/overrides").CDNInvalidationHandler>;
|
|
54
|
+
export declare function resolveCdnInvalidation(cdnInvalidation: OverrideOptions["cdnInvalidation"]): Promise<import("../types/overrides.js").CDNInvalidationHandler>;
|
|
55
55
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { InternalEvent, InternalResult, MiddlewareEvent, ResolvedRoute } from "../../types/open-next";
|
|
1
|
+
import type { InternalEvent, InternalResult, MiddlewareEvent, ResolvedRoute } from "../../types/open-next.js";
|
|
2
2
|
export declare function cacheInterceptor(event: MiddlewareEvent, resolvedRoutes?: ResolvedRoute[]): Promise<InternalEvent | InternalResult>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { AppPathsManifest, NextConfig, PagesManifest, PrerenderManifest, } from "../../adapters/config/index";
|
|
3
|
-
import { emptyReadableStream, toReadableStream } from "../../utils/stream";
|
|
4
|
-
import { isBinaryContentType } from "../../utils/binary";
|
|
5
|
-
import { getTagsFromValue, hasBeenRevalidated, isStale } from "../../utils/cache";
|
|
6
|
-
import { CACHE_CONTROL_HEADER, NO_STORE_CACHE_CONTROL, OPEN_NEXT_CACHE_HEADER, PRERENDER_REVALIDATE_HEADER, fixCacheControlForError, } from "../../utils/cacheHeaders";
|
|
7
|
-
import { getDynamicRouteCachePathname, getPrerenderRouteCacheKey, getRouteCacheKey, getRouteCacheOwner, useRouteCacheKeys, } from "../../utils/routeCacheKey";
|
|
2
|
+
import { AppPathsManifest, NextConfig, PagesManifest, PrerenderManifest, } from "../../adapters/config/index.js";
|
|
3
|
+
import { emptyReadableStream, toReadableStream } from "../../utils/stream.js";
|
|
4
|
+
import { isBinaryContentType } from "../../utils/binary.js";
|
|
5
|
+
import { getTagsFromValue, hasBeenRevalidated, isStale } from "../../utils/cache.js";
|
|
6
|
+
import { CACHE_CONTROL_HEADER, NO_STORE_CACHE_CONTROL, OPEN_NEXT_CACHE_HEADER, PRERENDER_REVALIDATE_HEADER, fixCacheControlForError, } from "../../utils/cacheHeaders.js";
|
|
7
|
+
import { getDynamicRouteCachePathname, getPrerenderRouteCacheKey, getRouteCacheKey, getRouteCacheOwner, useRouteCacheKeys, } from "../../utils/routeCacheKey.js";
|
|
8
8
|
import { debug } from "../../adapters/logger";
|
|
9
9
|
import { localizePath } from "./i18n";
|
|
10
10
|
import { generateMessageGroupId } from "./queue";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DomainLocale, i18nConfig } from "../../../types/next-types";
|
|
2
|
-
import type { InternalEvent, InternalResult } from "../../../types/open-next";
|
|
1
|
+
import type { DomainLocale, i18nConfig } from "../../../types/next-types.js";
|
|
2
|
+
import type { InternalEvent, InternalResult } from "../../../types/open-next.js";
|
|
3
3
|
/**
|
|
4
4
|
* @param arg an object containing the hostname and detectedLocale
|
|
5
5
|
* @returns The `DomainLocale` object if a domain is detected, `undefined` otherwise
|
|
@@ -1,12 +1,53 @@
|
|
|
1
|
-
import type { Header, PrerenderManifest, RedirectDefinition, RewriteDefinition } from "../../types/next-types";
|
|
2
|
-
import type { InternalEvent, InternalResult } from "../../types/open-next";
|
|
1
|
+
import type { Header, PrerenderManifest, RedirectDefinition, RewriteDefinition } from "../../types/next-types.js";
|
|
2
|
+
import type { InternalEvent, InternalResult } from "../../types/open-next.js";
|
|
3
|
+
/**
|
|
4
|
+
* Returns the compiled regular expression for a configured pattern.
|
|
5
|
+
*
|
|
6
|
+
* Patterns come from the Next.js config and manifests, so each one is compiled
|
|
7
|
+
* on first use and reused by later requests. `lastIndex` is reset on every call
|
|
8
|
+
* so a shared global or sticky expression always starts from the beginning.
|
|
9
|
+
*
|
|
10
|
+
* @param pattern The regular expression source
|
|
11
|
+
* @param flags The optional regular expression flags
|
|
12
|
+
* @returns The compiled regular expression
|
|
13
|
+
* @throws {SyntaxError} When the pattern is invalid
|
|
14
|
+
*/
|
|
15
|
+
export declare function getCompiledRegExp(pattern: string, flags?: string): RegExp;
|
|
16
|
+
/**
|
|
17
|
+
* Resolves configured response headers for a request.
|
|
18
|
+
*
|
|
19
|
+
* Source parameters are merged with successful condition parameters before
|
|
20
|
+
* interpolation, with condition parameters taking precedence. See
|
|
21
|
+
* https://github.com/vercel/next.js/blob/ae745ba/packages/next/src/server/lib/router-utils/resolve-routes.ts#L400-L414
|
|
22
|
+
*
|
|
23
|
+
* @param event The request used to match configured headers
|
|
24
|
+
* @param configHeaders The configured header routes
|
|
25
|
+
* @returns The response headers produced by every matching route
|
|
26
|
+
* @throws {SyntaxError} When a configured route pattern is invalid
|
|
27
|
+
*/
|
|
3
28
|
export declare function getNextConfigHeaders(event: InternalEvent, configHeaders?: Header[] | undefined): Record<string, string | undefined>;
|
|
4
29
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
30
|
+
* Applies the first matching rewrite to an internal request.
|
|
31
|
+
*
|
|
32
|
+
* Only successful `has` predicates supply destination parameters. Nonmatching
|
|
33
|
+
* `missing` predicates must not manufacture captures from absent values. See
|
|
34
|
+
* https://github.com/vercel/next.js/blob/ae745ba/packages/next/src/shared/lib/router/utils/prepare-destination.ts#L113-L125
|
|
35
|
+
*
|
|
36
|
+
* Destination queries use non-path compilation so repeated parameters retain
|
|
37
|
+
* their separators. See
|
|
38
|
+
* https://github.com/vercel/next.js/blob/ae745ba/packages/next/src/shared/lib/router/utils/prepare-destination.ts#L292-L302
|
|
39
|
+
*
|
|
40
|
+
* TODO: This method currently only checks the first match. It should check all
|
|
41
|
+
* matches for `beforeFiles` and `afterFiles` rewrites. See
|
|
42
|
+
* https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites
|
|
43
|
+
*
|
|
44
|
+
* @param event The request to rewrite
|
|
45
|
+
* @param rewrites The configured rewrites to evaluate
|
|
46
|
+
* @param appendParamsToQuery Whether unused match parameters are added to the query
|
|
47
|
+
* @returns The rewritten request and matched rewrite metadata
|
|
48
|
+
* @throws {TypeError} When a matched destination cannot be compiled
|
|
8
49
|
*/
|
|
9
|
-
export declare function handleRewrites<T extends RewriteDefinition>(event: InternalEvent, rewrites: T[]): {
|
|
50
|
+
export declare function handleRewrites<T extends RewriteDefinition>(event: InternalEvent, rewrites: T[], appendParamsToQuery?: boolean): {
|
|
10
51
|
internalEvent: {
|
|
11
52
|
query: Record<string, string | string[]>;
|
|
12
53
|
rawPath: string;
|
|
@@ -21,6 +62,20 @@ export declare function handleRewrites<T extends RewriteDefinition>(event: Inter
|
|
|
21
62
|
__rewrite: T | undefined;
|
|
22
63
|
isExternalRewrite: boolean;
|
|
23
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Applies every matching `beforeFiles` rewrite, in order.
|
|
67
|
+
*
|
|
68
|
+
* Next.js keeps evaluating `beforeFiles` rewrites after a match, each one
|
|
69
|
+
* against the URL produced by the previous match. An external rewrite ends the
|
|
70
|
+
* evaluation. See
|
|
71
|
+
* https://github.com/vercel/next.js/blob/ae745ba/packages/next/src/server/lib/router-utils/resolve-routes.ts#L863-L932
|
|
72
|
+
*
|
|
73
|
+
* @param event The request to rewrite
|
|
74
|
+
* @param rewrites The configured `beforeFiles` rewrites
|
|
75
|
+
* @returns The rewritten request and the last matched rewrite metadata
|
|
76
|
+
* @throws {TypeError} When a matched destination cannot be compiled
|
|
77
|
+
*/
|
|
78
|
+
export declare function handleBeforeFilesRewrites<T extends RewriteDefinition>(event: InternalEvent, rewrites: T[]): ReturnType<typeof handleRewrites<T>>;
|
|
24
79
|
export declare function handleRedirects(event: InternalEvent, redirects: RedirectDefinition[]): InternalResult | undefined;
|
|
25
80
|
export declare function fixDataPage(internalEvent: InternalEvent, buildId: string): InternalEvent | InternalResult;
|
|
26
81
|
export declare function handleFallbackFalse(internalEvent: InternalEvent, prerenderManifest?: PrerenderManifest): {
|