@netlify/plugin-nextjs 5.9.4 → 5.10.0
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/build/content/prerendered.js +2 -2
- package/dist/build/content/static.js +4 -2
- package/dist/build/functions/edge.js +1 -1
- package/dist/build/templates/handler-monorepo.tmpl.js +2 -1
- package/dist/build/templates/handler.tmpl.js +2 -1
- package/dist/esm-chunks/{chunk-OAVVYSTW.js → chunk-3RQSTU2O.js} +10 -2
- package/dist/esm-chunks/{chunk-BVYZSEV6.js → chunk-DLBTTDNJ.js} +8 -5
- package/dist/esm-chunks/{chunk-LVXJQ2G2.js → chunk-SGXRYMYQ.js} +0 -20
- package/dist/esm-chunks/{chunk-HWMLYAVP.js → chunk-VTKZZRGT.js} +13 -3
- package/dist/esm-chunks/{chunk-NEZW7TGG.js → chunk-WHUPSPWV.js} +1 -1
- package/dist/esm-chunks/{chunk-G3TOKXOX.js → chunk-YMNWVS6T.js} +22 -22
- package/dist/esm-chunks/{next-37W7QRMR.js → next-7JK63CHT.js} +2 -2
- package/dist/esm-chunks/{package-AJQOUMDK.js → package-F536DQ6H.js} +2 -2
- package/dist/index.js +7 -5
- package/dist/run/handlers/cache.cjs +79 -28
- package/dist/run/handlers/request-context.cjs +8 -3
- package/dist/run/handlers/server.js +23 -11
- package/dist/run/handlers/tracing.js +2 -2
- package/dist/run/headers.js +2 -2
- package/package.json +1 -1
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
import {
|
|
8
8
|
copyFetchContent,
|
|
9
9
|
copyPrerenderedContent
|
|
10
|
-
} from "../../esm-chunks/chunk-
|
|
11
|
-
import "../../esm-chunks/chunk-TYCYFZ22.js";
|
|
10
|
+
} from "../../esm-chunks/chunk-DLBTTDNJ.js";
|
|
12
11
|
import "../../esm-chunks/chunk-5QSXBV7L.js";
|
|
13
12
|
import "../../esm-chunks/chunk-GNGHTHMQ.js";
|
|
14
13
|
import "../../esm-chunks/chunk-ZSVHJNNY.js";
|
|
15
14
|
import "../../esm-chunks/chunk-KGYJQ2U2.js";
|
|
16
15
|
import "../../esm-chunks/chunk-ZENB67PD.js";
|
|
17
16
|
import "../../esm-chunks/chunk-APO262HE.js";
|
|
17
|
+
import "../../esm-chunks/chunk-TYCYFZ22.js";
|
|
18
18
|
import "../../esm-chunks/chunk-OEQOKJGE.js";
|
|
19
19
|
export {
|
|
20
20
|
copyFetchContent,
|
|
@@ -9,20 +9,22 @@ import {
|
|
|
9
9
|
copyStaticContent,
|
|
10
10
|
copyStaticExport,
|
|
11
11
|
publishStaticDir,
|
|
12
|
+
setHeadersConfig,
|
|
12
13
|
unpublishStaticDir
|
|
13
|
-
} from "../../esm-chunks/chunk-
|
|
14
|
-
import "../../esm-chunks/chunk-TYCYFZ22.js";
|
|
14
|
+
} from "../../esm-chunks/chunk-VTKZZRGT.js";
|
|
15
15
|
import "../../esm-chunks/chunk-5QSXBV7L.js";
|
|
16
16
|
import "../../esm-chunks/chunk-GNGHTHMQ.js";
|
|
17
17
|
import "../../esm-chunks/chunk-ZSVHJNNY.js";
|
|
18
18
|
import "../../esm-chunks/chunk-KGYJQ2U2.js";
|
|
19
19
|
import "../../esm-chunks/chunk-ZENB67PD.js";
|
|
20
20
|
import "../../esm-chunks/chunk-APO262HE.js";
|
|
21
|
+
import "../../esm-chunks/chunk-TYCYFZ22.js";
|
|
21
22
|
import "../../esm-chunks/chunk-OEQOKJGE.js";
|
|
22
23
|
export {
|
|
23
24
|
copyStaticAssets,
|
|
24
25
|
copyStaticContent,
|
|
25
26
|
copyStaticExport,
|
|
26
27
|
publishStaticDir,
|
|
28
|
+
setHeadersConfig,
|
|
27
29
|
unpublishStaticDir
|
|
28
30
|
};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {
|
|
8
8
|
clearStaleEdgeHandlers,
|
|
9
9
|
createEdgeHandlers
|
|
10
|
-
} from "../../esm-chunks/chunk-
|
|
10
|
+
} from "../../esm-chunks/chunk-3RQSTU2O.js";
|
|
11
11
|
import "../../esm-chunks/chunk-GFYWJNQR.js";
|
|
12
12
|
import "../../esm-chunks/chunk-KGYJQ2U2.js";
|
|
13
13
|
import "../../esm-chunks/chunk-APO262HE.js";
|
|
@@ -28,6 +28,7 @@ export default async function (req, context) {
|
|
|
28
28
|
'site.id': context.site.id,
|
|
29
29
|
'http.method': req.method,
|
|
30
30
|
'http.target': req.url,
|
|
31
|
+
isBackgroundRevalidation: requestContext.isBackgroundRevalidation,
|
|
31
32
|
monorepo: true,
|
|
32
33
|
cwd: '{{cwd}}',
|
|
33
34
|
})
|
|
@@ -35,7 +36,7 @@ export default async function (req, context) {
|
|
|
35
36
|
const { default: handler } = await import('{{nextServerHandler}}')
|
|
36
37
|
cachedHandler = handler
|
|
37
38
|
}
|
|
38
|
-
const response = await cachedHandler(req, context)
|
|
39
|
+
const response = await cachedHandler(req, context, span, requestContext)
|
|
39
40
|
span.setAttributes({
|
|
40
41
|
'http.status_code': response.status,
|
|
41
42
|
})
|
|
@@ -25,10 +25,11 @@ export default async function handler(req, context) {
|
|
|
25
25
|
'site.id': context.site.id,
|
|
26
26
|
'http.method': req.method,
|
|
27
27
|
'http.target': req.url,
|
|
28
|
+
isBackgroundRevalidation: requestContext.isBackgroundRevalidation,
|
|
28
29
|
monorepo: false,
|
|
29
30
|
cwd: process.cwd(),
|
|
30
31
|
})
|
|
31
|
-
const response = await serverHandler(req, context)
|
|
32
|
+
const response = await serverHandler(req, context, span, requestContext)
|
|
32
33
|
span.setAttributes({
|
|
33
34
|
'http.status_code': response.status,
|
|
34
35
|
})
|
|
@@ -427,13 +427,21 @@ var copyRuntime = async (ctx, handlerDirectory) => {
|
|
|
427
427
|
);
|
|
428
428
|
};
|
|
429
429
|
var augmentMatchers = (matchers, ctx) => {
|
|
430
|
-
|
|
430
|
+
const i18NConfig = ctx.buildConfig.i18n;
|
|
431
|
+
if (!i18NConfig) {
|
|
431
432
|
return matchers;
|
|
432
433
|
}
|
|
433
434
|
return matchers.flatMap((matcher) => {
|
|
434
435
|
if (matcher.originalSource && matcher.locale !== false) {
|
|
435
436
|
return [
|
|
436
|
-
matcher
|
|
437
|
+
matcher.regexp ? {
|
|
438
|
+
...matcher,
|
|
439
|
+
// https://github.com/vercel/next.js/blob/5e236c9909a768dc93856fdfad53d4f4adc2db99/packages/next/src/build/analysis/get-page-static-info.ts#L332-L336
|
|
440
|
+
// Next is producing pretty broad matcher for i18n locale. Presumably rest of their infrastructure protects this broad matcher
|
|
441
|
+
// from matching on non-locale paths. For us this becomes request entry point, so we need to narrow it down to just defined locales
|
|
442
|
+
// otherwise users might get unexpected matches on paths like `/api*`
|
|
443
|
+
regexp: matcher.regexp.replace(/\[\^\/\.]+/g, `(${i18NConfig.locales.join("|")})`)
|
|
444
|
+
} : matcher,
|
|
437
445
|
{
|
|
438
446
|
...matcher,
|
|
439
447
|
regexp: (0, import_path_to_regexp.pathToRegexp)(matcher.originalSource).source
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
return createRequire(import.meta.url);
|
|
5
5
|
})();
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
encodeBlobKey
|
|
9
|
-
} from "./chunk-TYCYFZ22.js";
|
|
10
7
|
import {
|
|
11
8
|
wrapTracer
|
|
12
9
|
} from "./chunk-5QSXBV7L.js";
|
|
@@ -23,6 +20,9 @@ import {
|
|
|
23
20
|
import {
|
|
24
21
|
require_semver
|
|
25
22
|
} from "./chunk-APO262HE.js";
|
|
23
|
+
import {
|
|
24
|
+
encodeBlobKey
|
|
25
|
+
} from "./chunk-TYCYFZ22.js";
|
|
26
26
|
import {
|
|
27
27
|
__toESM
|
|
28
28
|
} from "./chunk-OEQOKJGE.js";
|
|
@@ -160,12 +160,13 @@ var routeToFilePath = (path) => {
|
|
|
160
160
|
}
|
|
161
161
|
return `/${path}`;
|
|
162
162
|
};
|
|
163
|
-
var buildPagesCacheValue = async (path, shouldUseEnumKind, shouldSkipJson = false) => ({
|
|
163
|
+
var buildPagesCacheValue = async (path, initialRevalidateSeconds, shouldUseEnumKind, shouldSkipJson = false) => ({
|
|
164
164
|
kind: shouldUseEnumKind ? "PAGES" : "PAGE",
|
|
165
165
|
html: await readFile(`${path}.html`, "utf-8"),
|
|
166
166
|
pageData: shouldSkipJson ? {} : JSON.parse(await readFile(`${path}.json`, "utf-8")),
|
|
167
167
|
headers: void 0,
|
|
168
|
-
status: void 0
|
|
168
|
+
status: void 0,
|
|
169
|
+
revalidate: initialRevalidateSeconds
|
|
169
170
|
});
|
|
170
171
|
var buildAppCacheValue = async (path, shouldUseAppPageKind) => {
|
|
171
172
|
const meta = JSON.parse(await readFile(`${path}.meta`, "utf-8"));
|
|
@@ -231,6 +232,7 @@ var copyPrerenderedContent = async (ctx) => {
|
|
|
231
232
|
}
|
|
232
233
|
value = await buildPagesCacheValue(
|
|
233
234
|
join(ctx.publishDir, "server/pages", key),
|
|
235
|
+
meta.initialRevalidateSeconds,
|
|
234
236
|
shouldUseEnumKind
|
|
235
237
|
);
|
|
236
238
|
break;
|
|
@@ -260,6 +262,7 @@ var copyPrerenderedContent = async (ctx) => {
|
|
|
260
262
|
const key = routeToFilePath(route);
|
|
261
263
|
const value = await buildPagesCacheValue(
|
|
262
264
|
join(ctx.publishDir, "server/pages", key),
|
|
265
|
+
void 0,
|
|
263
266
|
shouldUseEnumKind,
|
|
264
267
|
true
|
|
265
268
|
// there is no corresponding json file for fallback, so we are skipping it for this entry
|
|
@@ -101,25 +101,6 @@ var init_internal = __esm({
|
|
|
101
101
|
init_internal();
|
|
102
102
|
|
|
103
103
|
// src/run/handlers/request-context.cts
|
|
104
|
-
function createRequestContext(request, context) {
|
|
105
|
-
const backgroundWorkPromises = [];
|
|
106
|
-
return {
|
|
107
|
-
captureServerTiming: request?.headers.has("x-next-debug-logging") ?? false,
|
|
108
|
-
trackBackgroundWork: (promise) => {
|
|
109
|
-
if (context?.waitUntil) {
|
|
110
|
-
context.waitUntil(promise);
|
|
111
|
-
} else {
|
|
112
|
-
backgroundWorkPromises.push(promise);
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
get backgroundWorkPromise() {
|
|
116
|
-
return Promise.allSettled(backgroundWorkPromises);
|
|
117
|
-
},
|
|
118
|
-
logger: systemLogger.withLogLevel(
|
|
119
|
-
request?.headers.has("x-nf-debug-logging") || request?.headers.has("x-next-debug-logging") ? LogLevel.Debug : LogLevel.Log
|
|
120
|
-
)
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
104
|
var REQUEST_CONTEXT_GLOBAL_KEY = Symbol.for("nf-request-context-async-local-storage");
|
|
124
105
|
var requestContextAsyncLocalStorage;
|
|
125
106
|
function getRequestContextAsyncLocalStorage() {
|
|
@@ -141,7 +122,6 @@ function getLogger() {
|
|
|
141
122
|
}
|
|
142
123
|
|
|
143
124
|
export {
|
|
144
|
-
createRequestContext,
|
|
145
125
|
getRequestContext,
|
|
146
126
|
getLogger
|
|
147
127
|
};
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
return createRequire(import.meta.url);
|
|
5
5
|
})();
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
encodeBlobKey
|
|
9
|
-
} from "./chunk-TYCYFZ22.js";
|
|
10
7
|
import {
|
|
11
8
|
wrapTracer
|
|
12
9
|
} from "./chunk-5QSXBV7L.js";
|
|
@@ -20,6 +17,9 @@ import {
|
|
|
20
17
|
import {
|
|
21
18
|
require_out
|
|
22
19
|
} from "./chunk-KGYJQ2U2.js";
|
|
20
|
+
import {
|
|
21
|
+
encodeBlobKey
|
|
22
|
+
} from "./chunk-TYCYFZ22.js";
|
|
23
23
|
import {
|
|
24
24
|
__toESM
|
|
25
25
|
} from "./chunk-OEQOKJGE.js";
|
|
@@ -80,6 +80,15 @@ var copyStaticAssets = async (ctx) => {
|
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
};
|
|
83
|
+
var setHeadersConfig = async (ctx) => {
|
|
84
|
+
const { basePath } = ctx.buildConfig;
|
|
85
|
+
ctx.netlifyConfig.headers.push({
|
|
86
|
+
for: `${basePath}/_next/static/*`,
|
|
87
|
+
values: {
|
|
88
|
+
"Cache-Control": "public, max-age=31536000, immutable"
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
};
|
|
83
92
|
var copyStaticExport = async (ctx) => {
|
|
84
93
|
await tracer.withActiveSpan("copyStaticExport", async () => {
|
|
85
94
|
if (!ctx.exportDetail?.outDirectory) {
|
|
@@ -116,6 +125,7 @@ var unpublishStaticDir = async (ctx) => {
|
|
|
116
125
|
export {
|
|
117
126
|
copyStaticContent,
|
|
118
127
|
copyStaticAssets,
|
|
128
|
+
setHeadersConfig,
|
|
119
129
|
copyStaticExport,
|
|
120
130
|
publishStaticDir,
|
|
121
131
|
unpublishStaticDir
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-K4RDUZYO.js";
|
|
10
10
|
import {
|
|
11
11
|
getLogger
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-SGXRYMYQ.js";
|
|
13
13
|
import {
|
|
14
14
|
encodeBlobKey
|
|
15
15
|
} from "./chunk-TYCYFZ22.js";
|
|
@@ -96,15 +96,6 @@ var adjustDateHeader = async ({
|
|
|
96
96
|
tracer,
|
|
97
97
|
requestContext
|
|
98
98
|
}) => {
|
|
99
|
-
const cacheState = headers.get("x-nextjs-cache");
|
|
100
|
-
const isServedFromCache = cacheState === "HIT" || cacheState === "STALE";
|
|
101
|
-
span.setAttributes({
|
|
102
|
-
"x-nextjs-cache": cacheState ?? void 0,
|
|
103
|
-
isServedFromCache
|
|
104
|
-
});
|
|
105
|
-
if (!isServedFromCache) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
99
|
const key = new URL(request.url).pathname;
|
|
109
100
|
let lastModified;
|
|
110
101
|
if (requestContext.responseCacheGetLastModified) {
|
|
@@ -148,23 +139,33 @@ var adjustDateHeader = async ({
|
|
|
148
139
|
headers.set("x-nextjs-date", headers.get("date") ?? lastModifiedDate.toUTCString());
|
|
149
140
|
headers.set("date", lastModifiedDate.toUTCString());
|
|
150
141
|
};
|
|
142
|
+
function setCacheControlFromRequestContext(headers, revalidate) {
|
|
143
|
+
const cdnCacheControl = (
|
|
144
|
+
// if we are serving already stale response, instruct edge to not attempt to cache that response
|
|
145
|
+
headers.get("x-nextjs-cache") === "STALE" ? "public, max-age=0, must-revalidate, durable" : `s-maxage=${revalidate || 31536e3}, stale-while-revalidate=31536000, durable`
|
|
146
|
+
);
|
|
147
|
+
headers.set("netlify-cdn-cache-control", cdnCacheControl);
|
|
148
|
+
}
|
|
151
149
|
var setCacheControlHeaders = ({ headers, status }, request, requestContext, nextConfig) => {
|
|
152
150
|
if (typeof requestContext.routeHandlerRevalidate !== "undefined" && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control")) {
|
|
153
|
-
|
|
154
|
-
// if we are serving already stale response, instruct edge to not attempt to cache that response
|
|
155
|
-
headers.get("x-nextjs-cache") === "STALE" ? "public, max-age=0, must-revalidate, durable" : `s-maxage=${requestContext.routeHandlerRevalidate === false ? 31536e3 : requestContext.routeHandlerRevalidate}, stale-while-revalidate=31536000, durable`
|
|
156
|
-
);
|
|
157
|
-
headers.set("netlify-cdn-cache-control", cdnCacheControl);
|
|
151
|
+
setCacheControlFromRequestContext(headers, requestContext.routeHandlerRevalidate);
|
|
158
152
|
return;
|
|
159
153
|
}
|
|
160
154
|
if (status === 308 && request.url.endsWith("/") !== nextConfig.trailingSlash) {
|
|
161
155
|
getLogger().withFields({ trailingSlash: nextConfig.trailingSlash, location: headers.get("location") }).log("NetlifyHeadersHandler.trailingSlashRedirect");
|
|
162
156
|
}
|
|
163
|
-
if (status === 404 && request.url.endsWith(".php")) {
|
|
164
|
-
headers.set("cache-control", "public, max-age=0, must-revalidate");
|
|
165
|
-
headers.set("netlify-cdn-cache-control", `max-age=31536000, durable`);
|
|
166
|
-
}
|
|
167
157
|
const cacheControl = headers.get("cache-control");
|
|
158
|
+
if (status === 404) {
|
|
159
|
+
if (request.url.endsWith(".php")) {
|
|
160
|
+
headers.set("cache-control", "public, max-age=0, must-revalidate");
|
|
161
|
+
headers.set("netlify-cdn-cache-control", `max-age=31536000, durable`);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (process.env.CACHE_404_PAGE && request.url.endsWith("/404") && ["GET", "HEAD"].includes(request.method)) {
|
|
165
|
+
setCacheControlFromRequestContext(headers, requestContext.pageHandlerRevalidate);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
168
169
|
if (cacheControl !== null && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control")) {
|
|
169
170
|
const browserCacheControl = omitHeaderValues(cacheControl, [
|
|
170
171
|
"s-maxage",
|
|
@@ -183,7 +184,7 @@ var setCacheControlHeaders = ({ headers, status }, request, requestContext, next
|
|
|
183
184
|
headers.set("netlify-cdn-cache-control", cdnCacheControl);
|
|
184
185
|
return;
|
|
185
186
|
}
|
|
186
|
-
if (cacheControl === null && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control") && requestContext.usedFsReadForNonFallback) {
|
|
187
|
+
if (cacheControl === null && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control") && requestContext.usedFsReadForNonFallback) {
|
|
187
188
|
headers.set("cache-control", "public, max-age=0, must-revalidate");
|
|
188
189
|
headers.set("netlify-cdn-cache-control", `max-age=31536000, durable`);
|
|
189
190
|
}
|
|
@@ -198,8 +199,7 @@ var NEXT_CACHE_TO_CACHE_STATUS = {
|
|
|
198
199
|
MISS: `fwd=miss`,
|
|
199
200
|
STALE: `hit; fwd=stale`
|
|
200
201
|
};
|
|
201
|
-
var setCacheStatusHeader = (headers) => {
|
|
202
|
-
const nextCache = headers.get("x-nextjs-cache");
|
|
202
|
+
var setCacheStatusHeader = (headers, nextCache) => {
|
|
203
203
|
if (typeof nextCache === "string") {
|
|
204
204
|
if (nextCache in NEXT_CACHE_TO_CACHE_STATUS) {
|
|
205
205
|
const cacheStatus = NEXT_CACHE_TO_CACHE_STATUS[nextCache];
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
getTracer
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WHUPSPWV.js";
|
|
10
10
|
import {
|
|
11
11
|
getRegionalBlobStore
|
|
12
12
|
} from "./chunk-K4RDUZYO.js";
|
|
13
13
|
import {
|
|
14
14
|
getRequestContext
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-SGXRYMYQ.js";
|
|
16
16
|
import "./chunk-5QSXBV7L.js";
|
|
17
17
|
import "./chunk-GNGHTHMQ.js";
|
|
18
18
|
import {
|
|
@@ -8,7 +8,7 @@ import "./chunk-OEQOKJGE.js";
|
|
|
8
8
|
|
|
9
9
|
// package.json
|
|
10
10
|
var name = "@netlify/plugin-nextjs";
|
|
11
|
-
var version = "5.
|
|
11
|
+
var version = "5.10.0";
|
|
12
12
|
var description = "Run Next.js seamlessly on Netlify";
|
|
13
13
|
var main = "./dist/index.js";
|
|
14
14
|
var type = "module";
|
|
@@ -78,7 +78,7 @@ var devDependencies = {
|
|
|
78
78
|
"@vercel/nft": "^0.27.0",
|
|
79
79
|
cheerio: "^1.0.0-rc.12",
|
|
80
80
|
"clean-package": "^2.2.0",
|
|
81
|
-
esbuild: "^0.
|
|
81
|
+
esbuild: "^0.25.0",
|
|
82
82
|
execa: "^8.0.1",
|
|
83
83
|
"fast-glob": "^3.3.2",
|
|
84
84
|
"fs-monkey": "^1.0.6",
|
package/dist/index.js
CHANGED
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
copyPrerenderedContent
|
|
9
|
-
} from "./esm-chunks/chunk-
|
|
9
|
+
} from "./esm-chunks/chunk-DLBTTDNJ.js";
|
|
10
10
|
import {
|
|
11
11
|
copyStaticAssets,
|
|
12
12
|
copyStaticContent,
|
|
13
13
|
copyStaticExport,
|
|
14
14
|
publishStaticDir,
|
|
15
|
+
setHeadersConfig,
|
|
15
16
|
unpublishStaticDir
|
|
16
|
-
} from "./esm-chunks/chunk-
|
|
17
|
-
import "./esm-chunks/chunk-TYCYFZ22.js";
|
|
17
|
+
} from "./esm-chunks/chunk-VTKZZRGT.js";
|
|
18
18
|
import {
|
|
19
19
|
clearStaleEdgeHandlers,
|
|
20
20
|
createEdgeHandlers
|
|
21
|
-
} from "./esm-chunks/chunk-
|
|
21
|
+
} from "./esm-chunks/chunk-3RQSTU2O.js";
|
|
22
22
|
import {
|
|
23
23
|
clearStaleServerHandlers,
|
|
24
24
|
createServerHandler
|
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
import "./esm-chunks/chunk-KGYJQ2U2.js";
|
|
50
50
|
import "./esm-chunks/chunk-ZENB67PD.js";
|
|
51
51
|
import "./esm-chunks/chunk-APO262HE.js";
|
|
52
|
+
import "./esm-chunks/chunk-TYCYFZ22.js";
|
|
52
53
|
import "./esm-chunks/chunk-UYKENJEU.js";
|
|
53
54
|
import "./esm-chunks/chunk-OEQOKJGE.js";
|
|
54
55
|
|
|
@@ -83,7 +84,7 @@ var onBuild = async (options) => {
|
|
|
83
84
|
await saveBuildCache(ctx);
|
|
84
85
|
}
|
|
85
86
|
if (ctx.buildConfig.output === "export") {
|
|
86
|
-
return Promise.all([copyStaticExport(ctx), setImageConfig(ctx)]);
|
|
87
|
+
return Promise.all([copyStaticExport(ctx), setHeadersConfig(ctx), setImageConfig(ctx)]);
|
|
87
88
|
}
|
|
88
89
|
await verifyAdvancedAPIRoutes(ctx);
|
|
89
90
|
await verifyNetlifyFormsWorkaround(ctx);
|
|
@@ -93,6 +94,7 @@ var onBuild = async (options) => {
|
|
|
93
94
|
copyPrerenderedContent(ctx),
|
|
94
95
|
createServerHandler(ctx),
|
|
95
96
|
createEdgeHandlers(ctx),
|
|
97
|
+
setHeadersConfig(ctx),
|
|
96
98
|
setImageConfig(ctx)
|
|
97
99
|
]);
|
|
98
100
|
});
|
|
@@ -203,7 +203,7 @@ var import_constants = require("next/dist/lib/constants.js");
|
|
|
203
203
|
|
|
204
204
|
// package.json
|
|
205
205
|
var name = "@netlify/plugin-nextjs";
|
|
206
|
-
var version = "5.
|
|
206
|
+
var version = "5.10.0";
|
|
207
207
|
|
|
208
208
|
// src/shared/cache-types.cts
|
|
209
209
|
var isCachedPageValue = (value) => value.kind === "PAGE" || value.kind === "PAGES";
|
|
@@ -1809,6 +1809,19 @@ var NetlifyCacheHandler = class {
|
|
|
1809
1809
|
const { encodeBlobKey: encodeBlobKey2 } = await Promise.resolve().then(() => (init_blobkey(), blobkey_exports));
|
|
1810
1810
|
return await encodeBlobKey2(key);
|
|
1811
1811
|
}
|
|
1812
|
+
getTTL(blob) {
|
|
1813
|
+
if (blob.value?.kind === "FETCH" || blob.value?.kind === "ROUTE" || blob.value?.kind === "APP_ROUTE" || blob.value?.kind === "PAGE" || blob.value?.kind === "PAGES" || blob.value?.kind === "APP_PAGE") {
|
|
1814
|
+
const { revalidate } = blob.value;
|
|
1815
|
+
if (typeof revalidate === "number") {
|
|
1816
|
+
const revalidateAfter = revalidate * 1e3 + blob.lastModified;
|
|
1817
|
+
return (revalidateAfter - Date.now()) / 1e3;
|
|
1818
|
+
}
|
|
1819
|
+
if (revalidate === false) {
|
|
1820
|
+
return "PERMANENT";
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
return "NOT SET";
|
|
1824
|
+
}
|
|
1812
1825
|
captureResponseCacheLastModified(cacheValue, key, getCacheKeySpan) {
|
|
1813
1826
|
if (cacheValue.value?.kind === "FETCH") {
|
|
1814
1827
|
return;
|
|
@@ -1871,28 +1884,38 @@ var NetlifyCacheHandler = class {
|
|
|
1871
1884
|
}
|
|
1872
1885
|
}
|
|
1873
1886
|
}
|
|
1874
|
-
async injectEntryToPrerenderManifest(key, revalidate) {
|
|
1875
|
-
if (this.options.serverDistDir && (typeof revalidate === "number" || revalidate === false)) {
|
|
1887
|
+
async injectEntryToPrerenderManifest(key, { revalidate, cacheControl }) {
|
|
1888
|
+
if (this.options.serverDistDir && (typeof revalidate === "number" || revalidate === false || typeof cacheControl !== "undefined")) {
|
|
1876
1889
|
try {
|
|
1877
1890
|
const { loadManifest } = await import("next/dist/server/load-manifest.js");
|
|
1878
1891
|
const prerenderManifest = loadManifest(
|
|
1879
1892
|
(0, import_node_path.join)(this.options.serverDistDir, "..", "prerender-manifest.json")
|
|
1880
1893
|
);
|
|
1881
|
-
|
|
1882
|
-
const {
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1894
|
+
if (typeof cacheControl !== "undefined") {
|
|
1895
|
+
const { SharedCacheControls } = await import(
|
|
1896
|
+
// @ts-expect-error supporting multiple next version, this module is not resolvable with currently used dev dependency
|
|
1897
|
+
// eslint-disable-next-line import/no-unresolved, n/no-missing-import
|
|
1898
|
+
"next/dist/server/lib/incremental-cache/shared-cache-controls.js"
|
|
1899
|
+
);
|
|
1900
|
+
const sharedCacheControls = new SharedCacheControls(prerenderManifest);
|
|
1901
|
+
sharedCacheControls.set(key, cacheControl);
|
|
1902
|
+
} else if (typeof revalidate === "number" || revalidate === false) {
|
|
1903
|
+
try {
|
|
1904
|
+
const { normalizePagePath } = await import("next/dist/shared/lib/page-path/normalize-page-path.js");
|
|
1905
|
+
prerenderManifest.routes[key] = {
|
|
1906
|
+
experimentalPPR: void 0,
|
|
1907
|
+
dataRoute: (0, import_posix.join)("/_next/data", `${normalizePagePath(key)}.json`),
|
|
1908
|
+
srcRoute: null,
|
|
1909
|
+
// FIXME: provide actual source route, however, when dynamically appending it doesn't really matter
|
|
1910
|
+
initialRevalidateSeconds: revalidate,
|
|
1911
|
+
// Pages routes do not have a prefetch data route.
|
|
1912
|
+
prefetchDataRoute: void 0
|
|
1913
|
+
};
|
|
1914
|
+
} catch {
|
|
1915
|
+
const { SharedRevalidateTimings } = await import("next/dist/server/lib/incremental-cache/shared-revalidate-timings.js");
|
|
1916
|
+
const sharedRevalidateTimings = new SharedRevalidateTimings(prerenderManifest);
|
|
1917
|
+
sharedRevalidateTimings.set(key, revalidate);
|
|
1918
|
+
}
|
|
1896
1919
|
}
|
|
1897
1920
|
} catch {
|
|
1898
1921
|
}
|
|
@@ -1914,16 +1937,35 @@ var NetlifyCacheHandler = class {
|
|
|
1914
1937
|
span.addEvent("Cache miss", { key, blobKey });
|
|
1915
1938
|
return null;
|
|
1916
1939
|
}
|
|
1940
|
+
const ttl = this.getTTL(blob);
|
|
1941
|
+
if (getRequestContext()?.isBackgroundRevalidation && typeof ttl === "number" && ttl < 0) {
|
|
1942
|
+
span.addEvent("Discarding stale entry due to SWR background revalidation request", {
|
|
1943
|
+
key,
|
|
1944
|
+
blobKey,
|
|
1945
|
+
ttl
|
|
1946
|
+
});
|
|
1947
|
+
getLogger().withFields({
|
|
1948
|
+
ttl,
|
|
1949
|
+
key
|
|
1950
|
+
}).debug(
|
|
1951
|
+
`[NetlifyCacheHandler.get] Discarding stale entry due to SWR background revalidation request: ${key}`
|
|
1952
|
+
);
|
|
1953
|
+
return null;
|
|
1954
|
+
}
|
|
1917
1955
|
const staleByTags = await this.checkCacheEntryStaleByTags(blob, ctx.tags, ctx.softTags);
|
|
1918
1956
|
if (staleByTags) {
|
|
1919
|
-
span.addEvent("Stale", { staleByTags });
|
|
1957
|
+
span.addEvent("Stale", { staleByTags, key, blobKey, ttl });
|
|
1920
1958
|
return null;
|
|
1921
1959
|
}
|
|
1922
1960
|
this.captureResponseCacheLastModified(blob, key, span);
|
|
1923
1961
|
this.captureCacheTags(blob.value, key);
|
|
1924
1962
|
switch (blob.value?.kind) {
|
|
1925
1963
|
case "FETCH":
|
|
1926
|
-
span.addEvent("FETCH", {
|
|
1964
|
+
span.addEvent("FETCH", {
|
|
1965
|
+
lastModified: blob.lastModified,
|
|
1966
|
+
revalidate: ctx.revalidate,
|
|
1967
|
+
ttl
|
|
1968
|
+
});
|
|
1927
1969
|
return {
|
|
1928
1970
|
lastModified: blob.lastModified,
|
|
1929
1971
|
value: blob.value
|
|
@@ -1932,7 +1974,9 @@ var NetlifyCacheHandler = class {
|
|
|
1932
1974
|
case "APP_ROUTE": {
|
|
1933
1975
|
span.addEvent(blob.value?.kind, {
|
|
1934
1976
|
lastModified: blob.lastModified,
|
|
1935
|
-
status: blob.value.status
|
|
1977
|
+
status: blob.value.status,
|
|
1978
|
+
revalidate: blob.value.revalidate,
|
|
1979
|
+
ttl
|
|
1936
1980
|
});
|
|
1937
1981
|
const valueWithoutRevalidate = this.captureRouteRevalidateAndRemoveFromObject(blob.value);
|
|
1938
1982
|
return {
|
|
@@ -1945,18 +1989,22 @@ var NetlifyCacheHandler = class {
|
|
|
1945
1989
|
}
|
|
1946
1990
|
case "PAGE":
|
|
1947
1991
|
case "PAGES": {
|
|
1948
|
-
span.addEvent(blob.value?.kind, { lastModified: blob.lastModified });
|
|
1949
1992
|
const { revalidate, ...restOfPageValue } = blob.value;
|
|
1950
|
-
|
|
1993
|
+
const requestContext = getRequestContext();
|
|
1994
|
+
if (requestContext) {
|
|
1995
|
+
requestContext.pageHandlerRevalidate = revalidate;
|
|
1996
|
+
}
|
|
1997
|
+
span.addEvent(blob.value?.kind, { lastModified: blob.lastModified, revalidate, ttl });
|
|
1998
|
+
await this.injectEntryToPrerenderManifest(key, blob.value);
|
|
1951
1999
|
return {
|
|
1952
2000
|
lastModified: blob.lastModified,
|
|
1953
2001
|
value: restOfPageValue
|
|
1954
2002
|
};
|
|
1955
2003
|
}
|
|
1956
2004
|
case "APP_PAGE": {
|
|
1957
|
-
span.addEvent(blob.value?.kind, { lastModified: blob.lastModified });
|
|
1958
2005
|
const { revalidate, rscData, ...restOfPageValue } = blob.value;
|
|
1959
|
-
|
|
2006
|
+
span.addEvent(blob.value?.kind, { lastModified: blob.lastModified, revalidate, ttl });
|
|
2007
|
+
await this.injectEntryToPrerenderManifest(key, blob.value);
|
|
1960
2008
|
return {
|
|
1961
2009
|
lastModified: blob.lastModified,
|
|
1962
2010
|
value: {
|
|
@@ -1978,20 +2026,23 @@ var NetlifyCacheHandler = class {
|
|
|
1978
2026
|
if (isCachedRouteValue(data)) {
|
|
1979
2027
|
return {
|
|
1980
2028
|
...data,
|
|
1981
|
-
revalidate: context2.revalidate,
|
|
2029
|
+
revalidate: context2.revalidate ?? context2.cacheControl?.revalidate,
|
|
2030
|
+
cacheControl: context2.cacheControl,
|
|
1982
2031
|
body: data.body.toString("base64")
|
|
1983
2032
|
};
|
|
1984
2033
|
}
|
|
1985
2034
|
if (isCachedPageValue(data)) {
|
|
1986
2035
|
return {
|
|
1987
2036
|
...data,
|
|
1988
|
-
revalidate: context2.revalidate
|
|
2037
|
+
revalidate: context2.revalidate ?? context2.cacheControl?.revalidate,
|
|
2038
|
+
cacheControl: context2.cacheControl
|
|
1989
2039
|
};
|
|
1990
2040
|
}
|
|
1991
2041
|
if (data?.kind === "APP_PAGE") {
|
|
1992
2042
|
return {
|
|
1993
2043
|
...data,
|
|
1994
|
-
revalidate: context2.revalidate,
|
|
2044
|
+
revalidate: context2.revalidate ?? context2.cacheControl?.revalidate,
|
|
2045
|
+
cacheControl: context2.cacheControl,
|
|
1995
2046
|
rscData: data.rscData?.toString("base64")
|
|
1996
2047
|
};
|
|
1997
2048
|
}
|
|
@@ -123,7 +123,14 @@ init_internal();
|
|
|
123
123
|
// src/run/handlers/request-context.cts
|
|
124
124
|
function createRequestContext(request, context) {
|
|
125
125
|
const backgroundWorkPromises = [];
|
|
126
|
+
const isDebugRequest = request?.headers.has("x-nf-debug-logging") || request?.headers.has("x-next-debug-logging");
|
|
127
|
+
const logger = systemLogger.withLogLevel(isDebugRequest ? LogLevel.Debug : LogLevel.Log);
|
|
128
|
+
const isBackgroundRevalidation = request?.headers.get("netlify-invocation-source") === "background-revalidation";
|
|
129
|
+
if (isBackgroundRevalidation) {
|
|
130
|
+
logger.debug("[NetlifyNextRuntime] Background revalidation request");
|
|
131
|
+
}
|
|
126
132
|
return {
|
|
133
|
+
isBackgroundRevalidation,
|
|
127
134
|
captureServerTiming: request?.headers.has("x-next-debug-logging") ?? false,
|
|
128
135
|
trackBackgroundWork: (promise) => {
|
|
129
136
|
if (context?.waitUntil) {
|
|
@@ -135,9 +142,7 @@ function createRequestContext(request, context) {
|
|
|
135
142
|
get backgroundWorkPromise() {
|
|
136
143
|
return Promise.allSettled(backgroundWorkPromises);
|
|
137
144
|
},
|
|
138
|
-
logger
|
|
139
|
-
request?.headers.has("x-nf-debug-logging") || request?.headers.has("x-next-debug-logging") ? LogLevel.Debug : LogLevel.Log
|
|
140
|
-
)
|
|
145
|
+
logger
|
|
141
146
|
};
|
|
142
147
|
}
|
|
143
148
|
var REQUEST_CONTEXT_GLOBAL_KEY = Symbol.for("nf-request-context-async-local-storage");
|
|
@@ -6,26 +6,25 @@
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
getTracer
|
|
9
|
-
} from "../../esm-chunks/chunk-
|
|
9
|
+
} from "../../esm-chunks/chunk-WHUPSPWV.js";
|
|
10
10
|
import {
|
|
11
11
|
adjustDateHeader,
|
|
12
12
|
setCacheControlHeaders,
|
|
13
13
|
setCacheStatusHeader,
|
|
14
14
|
setCacheTagsHeaders,
|
|
15
15
|
setVaryHeaders
|
|
16
|
-
} from "../../esm-chunks/chunk-
|
|
16
|
+
} from "../../esm-chunks/chunk-YMNWVS6T.js";
|
|
17
17
|
import "../../esm-chunks/chunk-K4RDUZYO.js";
|
|
18
18
|
import {
|
|
19
|
-
createRequestContext,
|
|
20
19
|
getLogger,
|
|
21
20
|
getRequestContext
|
|
22
|
-
} from "../../esm-chunks/chunk-
|
|
21
|
+
} from "../../esm-chunks/chunk-SGXRYMYQ.js";
|
|
23
22
|
import {
|
|
24
23
|
nextResponseProxy
|
|
25
24
|
} from "../../esm-chunks/chunk-XS27YRA5.js";
|
|
26
|
-
import "../../esm-chunks/chunk-TYCYFZ22.js";
|
|
27
25
|
import "../../esm-chunks/chunk-5QSXBV7L.js";
|
|
28
26
|
import "../../esm-chunks/chunk-GNGHTHMQ.js";
|
|
27
|
+
import "../../esm-chunks/chunk-TYCYFZ22.js";
|
|
29
28
|
import {
|
|
30
29
|
__commonJS,
|
|
31
30
|
__toESM
|
|
@@ -3124,7 +3123,7 @@ function setupWaitUntil() {
|
|
|
3124
3123
|
}
|
|
3125
3124
|
|
|
3126
3125
|
// src/run/handlers/server.ts
|
|
3127
|
-
var nextImportPromise = import("../../esm-chunks/next-
|
|
3126
|
+
var nextImportPromise = import("../../esm-chunks/next-7JK63CHT.js");
|
|
3128
3127
|
setupWaitUntil();
|
|
3129
3128
|
var nextHandler;
|
|
3130
3129
|
var nextConfig;
|
|
@@ -3141,7 +3140,7 @@ var disableFaultyTransferEncodingHandling = (res) => {
|
|
|
3141
3140
|
return originalStoreHeader.call(this, firstLine, headers);
|
|
3142
3141
|
};
|
|
3143
3142
|
};
|
|
3144
|
-
var server_default = async (request) => {
|
|
3143
|
+
var server_default = async (request, _context, topLevelSpan, requestContext) => {
|
|
3145
3144
|
const tracer = getTracer();
|
|
3146
3145
|
if (!nextHandler) {
|
|
3147
3146
|
await tracer.withActiveSpan("initialize next server", async () => {
|
|
@@ -3171,7 +3170,6 @@ var server_default = async (request) => {
|
|
|
3171
3170
|
}
|
|
3172
3171
|
});
|
|
3173
3172
|
disableFaultyTransferEncodingHandling(res);
|
|
3174
|
-
const requestContext = getRequestContext() ?? createRequestContext();
|
|
3175
3173
|
const resProxy = nextResponseProxy(res, requestContext);
|
|
3176
3174
|
const nextHandlerPromise = nextHandler(req, resProxy).catch((error) => {
|
|
3177
3175
|
getLogger().withError(error).error("next handler error");
|
|
@@ -3182,13 +3180,27 @@ var server_default = async (request) => {
|
|
|
3182
3180
|
});
|
|
3183
3181
|
const response = await toComputeResponse(resProxy);
|
|
3184
3182
|
if (requestContext.responseCacheKey) {
|
|
3185
|
-
|
|
3183
|
+
topLevelSpan.setAttribute("responseCacheKey", requestContext.responseCacheKey);
|
|
3184
|
+
}
|
|
3185
|
+
const nextCache = response.headers.get("x-nextjs-cache");
|
|
3186
|
+
const isServedFromNextCache = nextCache === "HIT" || nextCache === "STALE";
|
|
3187
|
+
topLevelSpan.setAttributes({
|
|
3188
|
+
"x-nextjs-cache": nextCache ?? void 0,
|
|
3189
|
+
isServedFromNextCache
|
|
3190
|
+
});
|
|
3191
|
+
if (isServedFromNextCache) {
|
|
3192
|
+
await adjustDateHeader({
|
|
3193
|
+
headers: response.headers,
|
|
3194
|
+
request,
|
|
3195
|
+
span,
|
|
3196
|
+
tracer,
|
|
3197
|
+
requestContext
|
|
3198
|
+
});
|
|
3186
3199
|
}
|
|
3187
|
-
await adjustDateHeader({ headers: response.headers, request, span, tracer, requestContext });
|
|
3188
3200
|
setCacheControlHeaders(response, request, requestContext, nextConfig);
|
|
3189
3201
|
setCacheTagsHeaders(response.headers, requestContext);
|
|
3190
3202
|
setVaryHeaders(response.headers, request, nextConfig);
|
|
3191
|
-
setCacheStatusHeader(response.headers);
|
|
3203
|
+
setCacheStatusHeader(response.headers, nextCache);
|
|
3192
3204
|
async function waitForBackgroundWork() {
|
|
3193
3205
|
await nextHandlerPromise;
|
|
3194
3206
|
res.emit("close");
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
getLogger
|
|
9
|
-
} from "../../esm-chunks/chunk-
|
|
9
|
+
} from "../../esm-chunks/chunk-SGXRYMYQ.js";
|
|
10
10
|
import {
|
|
11
11
|
esm_exports,
|
|
12
12
|
init_esm
|
|
@@ -68868,7 +68868,7 @@ var import_sdk_trace_node = __toESM(require_src20(), 1);
|
|
|
68868
68868
|
var import_semantic_conventions = __toESM(require_src(), 1);
|
|
68869
68869
|
var {
|
|
68870
68870
|
default: { version, name }
|
|
68871
|
-
} = await import("../../esm-chunks/package-
|
|
68871
|
+
} = await import("../../esm-chunks/package-F536DQ6H.js");
|
|
68872
68872
|
var sdk = new import_sdk_node.NodeSDK({
|
|
68873
68873
|
resource: new import_resources.Resource({
|
|
68874
68874
|
[import_semantic_conventions.SEMRESATTRS_SERVICE_NAME]: name,
|
package/dist/run/headers.js
CHANGED
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
setCacheStatusHeader,
|
|
11
11
|
setCacheTagsHeaders,
|
|
12
12
|
setVaryHeaders
|
|
13
|
-
} from "../esm-chunks/chunk-
|
|
13
|
+
} from "../esm-chunks/chunk-YMNWVS6T.js";
|
|
14
14
|
import "../esm-chunks/chunk-K4RDUZYO.js";
|
|
15
|
-
import "../esm-chunks/chunk-
|
|
15
|
+
import "../esm-chunks/chunk-SGXRYMYQ.js";
|
|
16
16
|
import "../esm-chunks/chunk-TYCYFZ22.js";
|
|
17
17
|
import "../esm-chunks/chunk-OEQOKJGE.js";
|
|
18
18
|
export {
|