@netlify/plugin-nextjs 5.7.1 → 5.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/content/prerendered.js +3 -2
- package/dist/build/content/server.js +2 -2
- package/dist/build/content/static.js +1 -1
- package/dist/build/functions/edge.js +24 -8
- package/dist/build/functions/server.js +1 -1
- package/dist/build/plugin-context.js +1 -4
- package/dist/build/verification.js +2 -2
- package/dist/esm-chunks/{chunk-EFGWM7RS.js → chunk-APO262HE.js} +28 -4
- package/dist/esm-chunks/{chunk-FHR56UHE.js → chunk-KGYJQ2U2.js} +58 -48
- package/dist/esm-chunks/{package-GZ5FMVI4.js → package-EEQP43EX.js} +12 -12
- package/dist/run/handlers/tracing.js +2152 -671
- package/dist/run/headers.js +2 -2
- package/dist/run/regional-blob-store.cjs +53 -24
- package/edge-runtime/lib/response.ts +9 -12
- package/edge-runtime/middleware.ts +0 -1
- package/package.json +1 -1
package/dist/run/headers.js
CHANGED
|
@@ -146,7 +146,7 @@ var setCacheControlHeaders = (headers, request, requestContext) => {
|
|
|
146
146
|
if (typeof requestContext.routeHandlerRevalidate !== "undefined" && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control")) {
|
|
147
147
|
const cdnCacheControl = (
|
|
148
148
|
// if we are serving already stale response, instruct edge to not attempt to cache that response
|
|
149
|
-
headers.get("x-nextjs-cache") === "STALE" ? "public, max-age=0, must-revalidate" : `s-maxage=${requestContext.routeHandlerRevalidate === false ? 31536e3 : requestContext.routeHandlerRevalidate}, stale-while-revalidate=31536000, durable`
|
|
149
|
+
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`
|
|
150
150
|
);
|
|
151
151
|
headers.set("netlify-cdn-cache-control", cdnCacheControl);
|
|
152
152
|
return;
|
|
@@ -159,7 +159,7 @@ var setCacheControlHeaders = (headers, request, requestContext) => {
|
|
|
159
159
|
]);
|
|
160
160
|
const cdnCacheControl = (
|
|
161
161
|
// if we are serving already stale response, instruct edge to not attempt to cache that response
|
|
162
|
-
headers.get("x-nextjs-cache") === "STALE" ? "public, max-age=0, must-revalidate" : [
|
|
162
|
+
headers.get("x-nextjs-cache") === "STALE" ? "public, max-age=0, must-revalidate, durable" : [
|
|
163
163
|
...getHeaderValueArray(cacheControl).map(
|
|
164
164
|
(value) => value === "stale-while-revalidate" ? "stale-while-revalidate=31536000" : value
|
|
165
165
|
),
|
|
@@ -24,7 +24,7 @@ __export(regional_blob_store_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(regional_blob_store_exports);
|
|
26
26
|
|
|
27
|
-
// node_modules/@netlify/blobs/dist/chunk-
|
|
27
|
+
// node_modules/@netlify/blobs/dist/chunk-GUEW34CP.js
|
|
28
28
|
var NF_ERROR = "x-nf-error";
|
|
29
29
|
var NF_REQUEST_ID = "x-nf-request-id";
|
|
30
30
|
var BlobsInternalError = class extends Error {
|
|
@@ -139,6 +139,20 @@ var BlobsConsistencyError = class extends Error {
|
|
|
139
139
|
this.name = "BlobsConsistencyError";
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
+
var REGION_AUTO = "auto";
|
|
143
|
+
var regions = {
|
|
144
|
+
"us-east-1": true,
|
|
145
|
+
"us-east-2": true
|
|
146
|
+
};
|
|
147
|
+
var isValidRegion = (input) => Object.keys(regions).includes(input);
|
|
148
|
+
var InvalidBlobsRegionError = class extends Error {
|
|
149
|
+
constructor(region) {
|
|
150
|
+
super(
|
|
151
|
+
`${region} is not a supported Netlify Blobs region. Supported values are: ${Object.keys(regions).join(", ")}.`
|
|
152
|
+
);
|
|
153
|
+
this.name = "InvalidBlobsRegionError";
|
|
154
|
+
}
|
|
155
|
+
};
|
|
142
156
|
var DEFAULT_RETRY_DELAY = getEnvironment().get("NODE_ENV") === "test" ? 1 : 5e3;
|
|
143
157
|
var MIN_RETRY_DELAY = 1e3;
|
|
144
158
|
var MAX_RETRY = 5;
|
|
@@ -306,6 +320,9 @@ var getClientOptions = (options, contextOverride) => {
|
|
|
306
320
|
if (!siteID || !token) {
|
|
307
321
|
throw new MissingBlobsEnvironmentError(["siteID", "token"]);
|
|
308
322
|
}
|
|
323
|
+
if (options.region !== void 0 && !isValidRegion(options.region)) {
|
|
324
|
+
throw new InvalidBlobsRegionError(options.region);
|
|
325
|
+
}
|
|
309
326
|
const clientOptions = {
|
|
310
327
|
apiURL: context.apiURL ?? options.apiURL,
|
|
311
328
|
consistency: options.consistency,
|
|
@@ -328,7 +345,11 @@ var Store = class _Store {
|
|
|
328
345
|
this.client = options.client;
|
|
329
346
|
if ("deployID" in options) {
|
|
330
347
|
_Store.validateDeployID(options.deployID);
|
|
331
|
-
|
|
348
|
+
let name = DEPLOY_STORE_PREFIX + options.deployID;
|
|
349
|
+
if (options.name) {
|
|
350
|
+
name += `:${options.name}`;
|
|
351
|
+
}
|
|
352
|
+
this.name = name;
|
|
332
353
|
} else if (options.name.startsWith(LEGACY_STORE_INTERNAL_PREFIX)) {
|
|
333
354
|
const storeName = options.name.slice(LEGACY_STORE_INTERNAL_PREFIX.length);
|
|
334
355
|
_Store.validateStoreName(storeName);
|
|
@@ -538,18 +559,28 @@ var Store = class _Store {
|
|
|
538
559
|
parameters: nextParameters,
|
|
539
560
|
storeName
|
|
540
561
|
});
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
562
|
+
let blobs = [];
|
|
563
|
+
let directories = [];
|
|
564
|
+
if (![200, 204, 404].includes(res.status)) {
|
|
565
|
+
throw new BlobsInternalError(res);
|
|
566
|
+
}
|
|
567
|
+
if (res.status === 404) {
|
|
545
568
|
done = true;
|
|
569
|
+
} else {
|
|
570
|
+
const page = await res.json();
|
|
571
|
+
if (page.next_cursor) {
|
|
572
|
+
currentCursor = page.next_cursor;
|
|
573
|
+
} else {
|
|
574
|
+
done = true;
|
|
575
|
+
}
|
|
576
|
+
blobs = (page.blobs ?? []).map(_Store.formatListResultBlob).filter(Boolean);
|
|
577
|
+
directories = page.directories ?? [];
|
|
546
578
|
}
|
|
547
|
-
const blobs = (page.blobs ?? []).map(_Store.formatListResultBlob).filter(Boolean);
|
|
548
579
|
return {
|
|
549
580
|
done: false,
|
|
550
581
|
value: {
|
|
551
582
|
blobs,
|
|
552
|
-
directories
|
|
583
|
+
directories
|
|
553
584
|
}
|
|
554
585
|
};
|
|
555
586
|
}
|
|
@@ -558,30 +589,28 @@ var Store = class _Store {
|
|
|
558
589
|
};
|
|
559
590
|
}
|
|
560
591
|
};
|
|
561
|
-
var getDeployStore = (
|
|
592
|
+
var getDeployStore = (input = {}) => {
|
|
562
593
|
const context = getEnvironmentContext();
|
|
594
|
+
const options = typeof input === "string" ? { name: input } : input;
|
|
563
595
|
const deployID = options.deployID ?? context.deployID;
|
|
564
596
|
if (!deployID) {
|
|
565
597
|
throw new MissingBlobsEnvironmentError(["deployID"]);
|
|
566
598
|
}
|
|
567
599
|
const clientOptions = getClientOptions(options, context);
|
|
568
|
-
if (
|
|
569
|
-
if (
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
'The Netlify Blobs client was initialized with `experimentalRegion: "auto"` which is not compatible with the `edgeURL` property; consider using `apiURL` instead'
|
|
579
|
-
);
|
|
600
|
+
if (!clientOptions.region) {
|
|
601
|
+
if (clientOptions.edgeURL || clientOptions.uncachedEdgeURL) {
|
|
602
|
+
if (!context.primaryRegion) {
|
|
603
|
+
throw new Error(
|
|
604
|
+
"When accessing a deploy store, the Netlify Blobs client needs to be configured with a region, and one was not found in the environment. To manually set the region, set the `region` property in the `getDeployStore` options."
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
clientOptions.region = context.primaryRegion;
|
|
608
|
+
} else {
|
|
609
|
+
clientOptions.region = REGION_AUTO;
|
|
580
610
|
}
|
|
581
|
-
clientOptions.region = options.experimentalRegion;
|
|
582
611
|
}
|
|
583
612
|
const client = new Client(clientOptions);
|
|
584
|
-
return new Store({ client, deployID });
|
|
613
|
+
return new Store({ client, deployID, name: options.name });
|
|
585
614
|
};
|
|
586
615
|
|
|
587
616
|
// src/run/regional-blob-store.cts
|
|
@@ -590,7 +619,7 @@ var getRegionalBlobStore = (args = {}) => {
|
|
|
590
619
|
return getDeployStore({
|
|
591
620
|
...args,
|
|
592
621
|
fetch: fetchBeforeNextPatchedIt,
|
|
593
|
-
|
|
622
|
+
region: process.env.USE_REGIONAL_BLOBS?.toUpperCase() === "TRUE" ? void 0 : "us-east-2"
|
|
594
623
|
});
|
|
595
624
|
};
|
|
596
625
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -24,7 +24,6 @@ interface BuildResponseOptions {
|
|
|
24
24
|
request: Request
|
|
25
25
|
result: FetchEventResult
|
|
26
26
|
nextConfig?: RequestData['nextConfig']
|
|
27
|
-
requestLocale?: string
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
export const buildResponse = async ({
|
|
@@ -33,7 +32,6 @@ export const buildResponse = async ({
|
|
|
33
32
|
request,
|
|
34
33
|
result,
|
|
35
34
|
nextConfig,
|
|
36
|
-
requestLocale,
|
|
37
35
|
}: BuildResponseOptions): Promise<Response | void> => {
|
|
38
36
|
logger
|
|
39
37
|
.withFields({ is_nextresponse_next: result.response.headers.has('x-middleware-next') })
|
|
@@ -197,11 +195,10 @@ export const buildResponse = async ({
|
|
|
197
195
|
return addMiddlewareHeaders(context.rewrite(target), res)
|
|
198
196
|
}
|
|
199
197
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
redirect = normalizeLocalizedTarget({ target: redirect, request, nextConfig, requestLocale })
|
|
198
|
+
if (redirect) {
|
|
199
|
+
redirect = normalizeLocalizedTarget({ target: redirect, request, nextConfig })
|
|
203
200
|
if (redirect === request.url) {
|
|
204
|
-
logger.withFields({
|
|
201
|
+
logger.withFields({ redirect_url: redirect }).debug('Redirect url is same as original url')
|
|
205
202
|
return
|
|
206
203
|
}
|
|
207
204
|
res.headers.set('location', redirect)
|
|
@@ -234,25 +231,25 @@ function normalizeLocalizedTarget({
|
|
|
234
231
|
target,
|
|
235
232
|
request,
|
|
236
233
|
nextConfig,
|
|
237
|
-
requestLocale,
|
|
238
234
|
}: {
|
|
239
235
|
target: string
|
|
240
236
|
request: Request
|
|
241
237
|
nextConfig?: RequestData['nextConfig']
|
|
242
|
-
|
|
243
|
-
}) {
|
|
238
|
+
}): string {
|
|
244
239
|
const targetUrl = new URL(target, request.url)
|
|
245
240
|
|
|
246
241
|
const normalizedTarget = normalizeLocalePath(targetUrl.pathname, nextConfig?.i18n?.locales)
|
|
247
242
|
|
|
248
|
-
const locale = normalizedTarget.detectedLocale ?? requestLocale
|
|
249
243
|
if (
|
|
250
|
-
|
|
244
|
+
normalizedTarget.detectedLocale &&
|
|
251
245
|
!normalizedTarget.pathname.startsWith(`/api/`) &&
|
|
252
246
|
!normalizedTarget.pathname.startsWith(`/_next/static/`)
|
|
253
247
|
) {
|
|
254
248
|
targetUrl.pathname =
|
|
255
|
-
addBasePath(
|
|
249
|
+
addBasePath(
|
|
250
|
+
`/${normalizedTarget.detectedLocale}${normalizedTarget.pathname}`,
|
|
251
|
+
nextConfig?.basePath,
|
|
252
|
+
) || `/`
|
|
256
253
|
} else {
|
|
257
254
|
targetUrl.pathname = addBasePath(normalizedTarget.pathname, nextConfig?.basePath) || `/`
|
|
258
255
|
}
|