@netlify/plugin-nextjs 5.9.4 → 5.10.0-fetch-patch-logs
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 +1 -1
- package/dist/build/content/static.js +3 -1
- 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-G3TOKXOX.js → chunk-HXVWGXWM.js} +23 -23
- package/dist/esm-chunks/{chunk-BVYZSEV6.js → chunk-JPTD4GEB.js} +5 -2
- package/dist/esm-chunks/{chunk-HWMLYAVP.js → chunk-MKMK7FBF.js} +10 -0
- package/dist/esm-chunks/{chunk-K4RDUZYO.js → chunk-RYJYZQ4X.js} +1 -0
- package/dist/esm-chunks/{chunk-LVXJQ2G2.js → chunk-SGXRYMYQ.js} +0 -20
- package/dist/esm-chunks/{chunk-NEZW7TGG.js → chunk-WHUPSPWV.js} +1 -1
- package/dist/esm-chunks/{next-37W7QRMR.js → next-LDOXJ7XH.js} +3 -3
- package/dist/esm-chunks/{package-AJQOUMDK.js → package-F536DQ6H.js} +2 -2
- package/dist/index.js +14 -12
- package/dist/run/handlers/cache.cjs +80 -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 +3 -3
- package/dist/run/next.cjs +1 -0
- package/dist/run/regional-blob-store.cjs +1 -0
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {
|
|
8
8
|
copyFetchContent,
|
|
9
9
|
copyPrerenderedContent
|
|
10
|
-
} from "../../esm-chunks/chunk-
|
|
10
|
+
} from "../../esm-chunks/chunk-JPTD4GEB.js";
|
|
11
11
|
import "../../esm-chunks/chunk-TYCYFZ22.js";
|
|
12
12
|
import "../../esm-chunks/chunk-5QSXBV7L.js";
|
|
13
13
|
import "../../esm-chunks/chunk-GNGHTHMQ.js";
|
|
@@ -9,8 +9,9 @@ import {
|
|
|
9
9
|
copyStaticContent,
|
|
10
10
|
copyStaticExport,
|
|
11
11
|
publishStaticDir,
|
|
12
|
+
setHeadersConfig,
|
|
12
13
|
unpublishStaticDir
|
|
13
|
-
} from "../../esm-chunks/chunk-
|
|
14
|
+
} from "../../esm-chunks/chunk-MKMK7FBF.js";
|
|
14
15
|
import "../../esm-chunks/chunk-TYCYFZ22.js";
|
|
15
16
|
import "../../esm-chunks/chunk-5QSXBV7L.js";
|
|
16
17
|
import "../../esm-chunks/chunk-GNGHTHMQ.js";
|
|
@@ -24,5 +25,6 @@ export {
|
|
|
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
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
getRegionalBlobStore
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-RYJYZQ4X.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];
|
|
@@ -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
|
|
@@ -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
|
|
@@ -597,6 +597,7 @@ var getDeployStore = (input = {}) => {
|
|
|
597
597
|
// src/run/regional-blob-store.cts
|
|
598
598
|
var fetchBeforeNextPatchedIt = globalThis.fetch;
|
|
599
599
|
var getRegionalBlobStore = (args = {}) => {
|
|
600
|
+
console.log("Blob store fetch patched", fetchBeforeNextPatchedIt.__nextPatched);
|
|
600
601
|
return getDeployStore({
|
|
601
602
|
...args,
|
|
602
603
|
fetch: fetchBeforeNextPatchedIt,
|
|
@@ -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
|
};
|
|
@@ -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
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-RYJYZQ4X.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
|
@@ -4,26 +4,27 @@
|
|
|
4
4
|
return createRequire(import.meta.url);
|
|
5
5
|
})();
|
|
6
6
|
|
|
7
|
+
import {
|
|
8
|
+
clearStaleEdgeHandlers,
|
|
9
|
+
createEdgeHandlers
|
|
10
|
+
} from "./esm-chunks/chunk-3RQSTU2O.js";
|
|
11
|
+
import {
|
|
12
|
+
clearStaleServerHandlers,
|
|
13
|
+
createServerHandler
|
|
14
|
+
} from "./esm-chunks/chunk-DLVROEVU.js";
|
|
7
15
|
import {
|
|
8
16
|
copyPrerenderedContent
|
|
9
|
-
} from "./esm-chunks/chunk-
|
|
17
|
+
} from "./esm-chunks/chunk-JPTD4GEB.js";
|
|
18
|
+
import "./esm-chunks/chunk-IJZEDP6B.js";
|
|
10
19
|
import {
|
|
11
20
|
copyStaticAssets,
|
|
12
21
|
copyStaticContent,
|
|
13
22
|
copyStaticExport,
|
|
14
23
|
publishStaticDir,
|
|
24
|
+
setHeadersConfig,
|
|
15
25
|
unpublishStaticDir
|
|
16
|
-
} from "./esm-chunks/chunk-
|
|
26
|
+
} from "./esm-chunks/chunk-MKMK7FBF.js";
|
|
17
27
|
import "./esm-chunks/chunk-TYCYFZ22.js";
|
|
18
|
-
import {
|
|
19
|
-
clearStaleEdgeHandlers,
|
|
20
|
-
createEdgeHandlers
|
|
21
|
-
} from "./esm-chunks/chunk-OAVVYSTW.js";
|
|
22
|
-
import {
|
|
23
|
-
clearStaleServerHandlers,
|
|
24
|
-
createServerHandler
|
|
25
|
-
} from "./esm-chunks/chunk-DLVROEVU.js";
|
|
26
|
-
import "./esm-chunks/chunk-IJZEDP6B.js";
|
|
27
28
|
import {
|
|
28
29
|
wrapTracer
|
|
29
30
|
} from "./esm-chunks/chunk-5QSXBV7L.js";
|
|
@@ -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";
|
|
@@ -801,6 +801,7 @@ var getDeployStore = (input = {}) => {
|
|
|
801
801
|
// src/run/regional-blob-store.cts
|
|
802
802
|
var fetchBeforeNextPatchedIt = globalThis.fetch;
|
|
803
803
|
var getRegionalBlobStore = (args = {}) => {
|
|
804
|
+
console.log("Blob store fetch patched", fetchBeforeNextPatchedIt.__nextPatched);
|
|
804
805
|
return getDeployStore({
|
|
805
806
|
...args,
|
|
806
807
|
fetch: fetchBeforeNextPatchedIt,
|
|
@@ -1809,6 +1810,19 @@ var NetlifyCacheHandler = class {
|
|
|
1809
1810
|
const { encodeBlobKey: encodeBlobKey2 } = await Promise.resolve().then(() => (init_blobkey(), blobkey_exports));
|
|
1810
1811
|
return await encodeBlobKey2(key);
|
|
1811
1812
|
}
|
|
1813
|
+
getTTL(blob) {
|
|
1814
|
+
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") {
|
|
1815
|
+
const { revalidate } = blob.value;
|
|
1816
|
+
if (typeof revalidate === "number") {
|
|
1817
|
+
const revalidateAfter = revalidate * 1e3 + blob.lastModified;
|
|
1818
|
+
return (revalidateAfter - Date.now()) / 1e3;
|
|
1819
|
+
}
|
|
1820
|
+
if (revalidate === false) {
|
|
1821
|
+
return "PERMANENT";
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
return "NOT SET";
|
|
1825
|
+
}
|
|
1812
1826
|
captureResponseCacheLastModified(cacheValue, key, getCacheKeySpan) {
|
|
1813
1827
|
if (cacheValue.value?.kind === "FETCH") {
|
|
1814
1828
|
return;
|
|
@@ -1871,28 +1885,38 @@ var NetlifyCacheHandler = class {
|
|
|
1871
1885
|
}
|
|
1872
1886
|
}
|
|
1873
1887
|
}
|
|
1874
|
-
async injectEntryToPrerenderManifest(key, revalidate) {
|
|
1875
|
-
if (this.options.serverDistDir && (typeof revalidate === "number" || revalidate === false)) {
|
|
1888
|
+
async injectEntryToPrerenderManifest(key, { revalidate, cacheControl }) {
|
|
1889
|
+
if (this.options.serverDistDir && (typeof revalidate === "number" || revalidate === false || typeof cacheControl !== "undefined")) {
|
|
1876
1890
|
try {
|
|
1877
1891
|
const { loadManifest } = await import("next/dist/server/load-manifest.js");
|
|
1878
1892
|
const prerenderManifest = loadManifest(
|
|
1879
1893
|
(0, import_node_path.join)(this.options.serverDistDir, "..", "prerender-manifest.json")
|
|
1880
1894
|
);
|
|
1881
|
-
|
|
1882
|
-
const {
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1895
|
+
if (typeof cacheControl !== "undefined") {
|
|
1896
|
+
const { SharedCacheControls } = await import(
|
|
1897
|
+
// @ts-expect-error supporting multiple next version, this module is not resolvable with currently used dev dependency
|
|
1898
|
+
// eslint-disable-next-line import/no-unresolved, n/no-missing-import
|
|
1899
|
+
"next/dist/server/lib/incremental-cache/shared-cache-controls.js"
|
|
1900
|
+
);
|
|
1901
|
+
const sharedCacheControls = new SharedCacheControls(prerenderManifest);
|
|
1902
|
+
sharedCacheControls.set(key, cacheControl);
|
|
1903
|
+
} else if (typeof revalidate === "number" || revalidate === false) {
|
|
1904
|
+
try {
|
|
1905
|
+
const { normalizePagePath } = await import("next/dist/shared/lib/page-path/normalize-page-path.js");
|
|
1906
|
+
prerenderManifest.routes[key] = {
|
|
1907
|
+
experimentalPPR: void 0,
|
|
1908
|
+
dataRoute: (0, import_posix.join)("/_next/data", `${normalizePagePath(key)}.json`),
|
|
1909
|
+
srcRoute: null,
|
|
1910
|
+
// FIXME: provide actual source route, however, when dynamically appending it doesn't really matter
|
|
1911
|
+
initialRevalidateSeconds: revalidate,
|
|
1912
|
+
// Pages routes do not have a prefetch data route.
|
|
1913
|
+
prefetchDataRoute: void 0
|
|
1914
|
+
};
|
|
1915
|
+
} catch {
|
|
1916
|
+
const { SharedRevalidateTimings } = await import("next/dist/server/lib/incremental-cache/shared-revalidate-timings.js");
|
|
1917
|
+
const sharedRevalidateTimings = new SharedRevalidateTimings(prerenderManifest);
|
|
1918
|
+
sharedRevalidateTimings.set(key, revalidate);
|
|
1919
|
+
}
|
|
1896
1920
|
}
|
|
1897
1921
|
} catch {
|
|
1898
1922
|
}
|
|
@@ -1914,16 +1938,35 @@ var NetlifyCacheHandler = class {
|
|
|
1914
1938
|
span.addEvent("Cache miss", { key, blobKey });
|
|
1915
1939
|
return null;
|
|
1916
1940
|
}
|
|
1941
|
+
const ttl = this.getTTL(blob);
|
|
1942
|
+
if (getRequestContext()?.isBackgroundRevalidation && typeof ttl === "number" && ttl < 0) {
|
|
1943
|
+
span.addEvent("Discarding stale entry due to SWR background revalidation request", {
|
|
1944
|
+
key,
|
|
1945
|
+
blobKey,
|
|
1946
|
+
ttl
|
|
1947
|
+
});
|
|
1948
|
+
getLogger().withFields({
|
|
1949
|
+
ttl,
|
|
1950
|
+
key
|
|
1951
|
+
}).debug(
|
|
1952
|
+
`[NetlifyCacheHandler.get] Discarding stale entry due to SWR background revalidation request: ${key}`
|
|
1953
|
+
);
|
|
1954
|
+
return null;
|
|
1955
|
+
}
|
|
1917
1956
|
const staleByTags = await this.checkCacheEntryStaleByTags(blob, ctx.tags, ctx.softTags);
|
|
1918
1957
|
if (staleByTags) {
|
|
1919
|
-
span.addEvent("Stale", { staleByTags });
|
|
1958
|
+
span.addEvent("Stale", { staleByTags, key, blobKey, ttl });
|
|
1920
1959
|
return null;
|
|
1921
1960
|
}
|
|
1922
1961
|
this.captureResponseCacheLastModified(blob, key, span);
|
|
1923
1962
|
this.captureCacheTags(blob.value, key);
|
|
1924
1963
|
switch (blob.value?.kind) {
|
|
1925
1964
|
case "FETCH":
|
|
1926
|
-
span.addEvent("FETCH", {
|
|
1965
|
+
span.addEvent("FETCH", {
|
|
1966
|
+
lastModified: blob.lastModified,
|
|
1967
|
+
revalidate: ctx.revalidate,
|
|
1968
|
+
ttl
|
|
1969
|
+
});
|
|
1927
1970
|
return {
|
|
1928
1971
|
lastModified: blob.lastModified,
|
|
1929
1972
|
value: blob.value
|
|
@@ -1932,7 +1975,9 @@ var NetlifyCacheHandler = class {
|
|
|
1932
1975
|
case "APP_ROUTE": {
|
|
1933
1976
|
span.addEvent(blob.value?.kind, {
|
|
1934
1977
|
lastModified: blob.lastModified,
|
|
1935
|
-
status: blob.value.status
|
|
1978
|
+
status: blob.value.status,
|
|
1979
|
+
revalidate: blob.value.revalidate,
|
|
1980
|
+
ttl
|
|
1936
1981
|
});
|
|
1937
1982
|
const valueWithoutRevalidate = this.captureRouteRevalidateAndRemoveFromObject(blob.value);
|
|
1938
1983
|
return {
|
|
@@ -1945,18 +1990,22 @@ var NetlifyCacheHandler = class {
|
|
|
1945
1990
|
}
|
|
1946
1991
|
case "PAGE":
|
|
1947
1992
|
case "PAGES": {
|
|
1948
|
-
span.addEvent(blob.value?.kind, { lastModified: blob.lastModified });
|
|
1949
1993
|
const { revalidate, ...restOfPageValue } = blob.value;
|
|
1950
|
-
|
|
1994
|
+
const requestContext = getRequestContext();
|
|
1995
|
+
if (requestContext) {
|
|
1996
|
+
requestContext.pageHandlerRevalidate = revalidate;
|
|
1997
|
+
}
|
|
1998
|
+
span.addEvent(blob.value?.kind, { lastModified: blob.lastModified, revalidate, ttl });
|
|
1999
|
+
await this.injectEntryToPrerenderManifest(key, blob.value);
|
|
1951
2000
|
return {
|
|
1952
2001
|
lastModified: blob.lastModified,
|
|
1953
2002
|
value: restOfPageValue
|
|
1954
2003
|
};
|
|
1955
2004
|
}
|
|
1956
2005
|
case "APP_PAGE": {
|
|
1957
|
-
span.addEvent(blob.value?.kind, { lastModified: blob.lastModified });
|
|
1958
2006
|
const { revalidate, rscData, ...restOfPageValue } = blob.value;
|
|
1959
|
-
|
|
2007
|
+
span.addEvent(blob.value?.kind, { lastModified: blob.lastModified, revalidate, ttl });
|
|
2008
|
+
await this.injectEntryToPrerenderManifest(key, blob.value);
|
|
1960
2009
|
return {
|
|
1961
2010
|
lastModified: blob.lastModified,
|
|
1962
2011
|
value: {
|
|
@@ -1978,20 +2027,23 @@ var NetlifyCacheHandler = class {
|
|
|
1978
2027
|
if (isCachedRouteValue(data)) {
|
|
1979
2028
|
return {
|
|
1980
2029
|
...data,
|
|
1981
|
-
revalidate: context2.revalidate,
|
|
2030
|
+
revalidate: context2.revalidate ?? context2.cacheControl?.revalidate,
|
|
2031
|
+
cacheControl: context2.cacheControl,
|
|
1982
2032
|
body: data.body.toString("base64")
|
|
1983
2033
|
};
|
|
1984
2034
|
}
|
|
1985
2035
|
if (isCachedPageValue(data)) {
|
|
1986
2036
|
return {
|
|
1987
2037
|
...data,
|
|
1988
|
-
revalidate: context2.revalidate
|
|
2038
|
+
revalidate: context2.revalidate ?? context2.cacheControl?.revalidate,
|
|
2039
|
+
cacheControl: context2.cacheControl
|
|
1989
2040
|
};
|
|
1990
2041
|
}
|
|
1991
2042
|
if (data?.kind === "APP_PAGE") {
|
|
1992
2043
|
return {
|
|
1993
2044
|
...data,
|
|
1994
|
-
revalidate: context2.revalidate,
|
|
2045
|
+
revalidate: context2.revalidate ?? context2.cacheControl?.revalidate,
|
|
2046
|
+
cacheControl: context2.cacheControl,
|
|
1995
2047
|
rscData: data.rscData?.toString("base64")
|
|
1996
2048
|
};
|
|
1997
2049
|
}
|
|
@@ -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,20 +6,19 @@
|
|
|
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-
|
|
17
|
-
import "../../esm-chunks/chunk-
|
|
16
|
+
} from "../../esm-chunks/chunk-HXVWGXWM.js";
|
|
17
|
+
import "../../esm-chunks/chunk-RYJYZQ4X.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";
|
|
@@ -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-LDOXJ7XH.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-
|
|
14
|
-
import "../esm-chunks/chunk-
|
|
15
|
-
import "../esm-chunks/chunk-
|
|
13
|
+
} from "../esm-chunks/chunk-HXVWGXWM.js";
|
|
14
|
+
import "../esm-chunks/chunk-RYJYZQ4X.js";
|
|
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 {
|
package/dist/run/next.cjs
CHANGED
|
@@ -2098,6 +2098,7 @@ var getDeployStore = (input = {}) => {
|
|
|
2098
2098
|
// src/run/regional-blob-store.cts
|
|
2099
2099
|
var fetchBeforeNextPatchedIt = globalThis.fetch;
|
|
2100
2100
|
var getRegionalBlobStore = (args = {}) => {
|
|
2101
|
+
console.log("Blob store fetch patched", fetchBeforeNextPatchedIt.__nextPatched);
|
|
2101
2102
|
return getDeployStore({
|
|
2102
2103
|
...args,
|
|
2103
2104
|
fetch: fetchBeforeNextPatchedIt,
|
|
@@ -616,6 +616,7 @@ var getDeployStore = (input = {}) => {
|
|
|
616
616
|
// src/run/regional-blob-store.cts
|
|
617
617
|
var fetchBeforeNextPatchedIt = globalThis.fetch;
|
|
618
618
|
var getRegionalBlobStore = (args = {}) => {
|
|
619
|
+
console.log("Blob store fetch patched", fetchBeforeNextPatchedIt.__nextPatched);
|
|
619
620
|
return getDeployStore({
|
|
620
621
|
...args,
|
|
621
622
|
fetch: fetchBeforeNextPatchedIt,
|