@netlify/plugin-nextjs 5.9.3-background-debug-logs.0 → 5.9.4

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.
@@ -7,14 +7,14 @@
7
7
  import {
8
8
  copyFetchContent,
9
9
  copyPrerenderedContent
10
- } from "../../esm-chunks/chunk-J4D25YDX.js";
10
+ } from "../../esm-chunks/chunk-BVYZSEV6.js";
11
+ import "../../esm-chunks/chunk-TYCYFZ22.js";
11
12
  import "../../esm-chunks/chunk-5QSXBV7L.js";
12
13
  import "../../esm-chunks/chunk-GNGHTHMQ.js";
13
14
  import "../../esm-chunks/chunk-ZSVHJNNY.js";
14
15
  import "../../esm-chunks/chunk-KGYJQ2U2.js";
15
16
  import "../../esm-chunks/chunk-ZENB67PD.js";
16
17
  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,
@@ -10,14 +10,14 @@ import {
10
10
  copyStaticExport,
11
11
  publishStaticDir,
12
12
  unpublishStaticDir
13
- } from "../../esm-chunks/chunk-NTLBFRPA.js";
13
+ } from "../../esm-chunks/chunk-HWMLYAVP.js";
14
+ import "../../esm-chunks/chunk-TYCYFZ22.js";
14
15
  import "../../esm-chunks/chunk-5QSXBV7L.js";
15
16
  import "../../esm-chunks/chunk-GNGHTHMQ.js";
16
17
  import "../../esm-chunks/chunk-ZSVHJNNY.js";
17
18
  import "../../esm-chunks/chunk-KGYJQ2U2.js";
18
19
  import "../../esm-chunks/chunk-ZENB67PD.js";
19
20
  import "../../esm-chunks/chunk-APO262HE.js";
20
- import "../../esm-chunks/chunk-TYCYFZ22.js";
21
21
  import "../../esm-chunks/chunk-OEQOKJGE.js";
22
22
  export {
23
23
  copyStaticAssets,
@@ -7,7 +7,7 @@
7
7
  import {
8
8
  clearStaleEdgeHandlers,
9
9
  createEdgeHandlers
10
- } from "../../esm-chunks/chunk-HGXG447M.js";
10
+ } from "../../esm-chunks/chunk-OAVVYSTW.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";
@@ -7,6 +7,9 @@
7
7
  import {
8
8
  getRegionalBlobStore
9
9
  } from "./chunk-K4RDUZYO.js";
10
+ import {
11
+ getLogger
12
+ } from "./chunk-LVXJQ2G2.js";
10
13
  import {
11
14
  encodeBlobKey
12
15
  } from "./chunk-TYCYFZ22.js";
@@ -145,7 +148,7 @@ var adjustDateHeader = async ({
145
148
  headers.set("x-nextjs-date", headers.get("date") ?? lastModifiedDate.toUTCString());
146
149
  headers.set("date", lastModifiedDate.toUTCString());
147
150
  };
148
- var setCacheControlHeaders = ({ headers, status }, request, requestContext) => {
151
+ var setCacheControlHeaders = ({ headers, status }, request, requestContext, nextConfig) => {
149
152
  if (typeof requestContext.routeHandlerRevalidate !== "undefined" && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control")) {
150
153
  const cdnCacheControl = (
151
154
  // if we are serving already stale response, instruct edge to not attempt to cache that response
@@ -154,6 +157,9 @@ var setCacheControlHeaders = ({ headers, status }, request, requestContext) => {
154
157
  headers.set("netlify-cdn-cache-control", cdnCacheControl);
155
158
  return;
156
159
  }
160
+ if (status === 308 && request.url.endsWith("/") !== nextConfig.trailingSlash) {
161
+ getLogger().withFields({ trailingSlash: nextConfig.trailingSlash, location: headers.get("location") }).log("NetlifyHeadersHandler.trailingSlashRedirect");
162
+ }
157
163
  if (status === 404 && request.url.endsWith(".php")) {
158
164
  headers.set("cache-control", "public, max-age=0, must-revalidate");
159
165
  headers.set("netlify-cdn-cache-control", `max-age=31536000, durable`);
@@ -103,22 +103,13 @@ init_internal();
103
103
  // src/run/handlers/request-context.cts
104
104
  function createRequestContext(request, context) {
105
105
  const backgroundWorkPromises = [];
106
- let backgroundWorkCounter = 0;
107
106
  return {
108
107
  captureServerTiming: request?.headers.has("x-next-debug-logging") ?? false,
109
- trackBackgroundWork: (promise, description) => {
110
- backgroundWorkCounter += 1;
111
- const counter = backgroundWorkCounter;
112
- const label = `background #${counter} - ${description ?? "unknown"} - ${context?.requestId}`;
113
- const start = Date.now();
114
- console.log(`Start ${label}`);
115
- const trackedPromise = promise.finally(() => {
116
- console.log(`End ${label} - ${(Date.now() - start) / 1e3}s`);
117
- });
108
+ trackBackgroundWork: (promise) => {
118
109
  if (context?.waitUntil) {
119
- context.waitUntil(trackedPromise);
110
+ context.waitUntil(promise);
120
111
  } else {
121
- backgroundWorkPromises.push(trackedPromise);
112
+ backgroundWorkPromises.push(promise);
122
113
  }
123
114
  },
124
115
  get backgroundWorkPromise() {
@@ -6,7 +6,7 @@
6
6
 
7
7
  import {
8
8
  getRequestContext
9
- } from "./chunk-FB56KFLR.js";
9
+ } from "./chunk-LVXJQ2G2.js";
10
10
  import {
11
11
  wrapTracer
12
12
  } from "./chunk-5QSXBV7L.js";
@@ -409,9 +409,7 @@ var require_dist = __commonJS({
409
409
  var import_fast_glob = __toESM(require_out(), 1);
410
410
  var import_path_to_regexp = __toESM(require_dist(), 1);
411
411
  import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
412
- import { dirname, join, relative, sep } from "node:path";
413
- import { sep as posixSep } from "node:path/posix";
414
- var toPosixPath = (path) => path.split(sep).join(posixSep);
412
+ import { dirname, join } from "node:path";
415
413
  var writeEdgeManifest = async (ctx, manifest) => {
416
414
  await mkdir(ctx.edgeFunctionsDir, { recursive: true });
417
415
  await writeFile(join(ctx.edgeFunctionsDir, "manifest.json"), JSON.stringify(manifest, null, 2));
@@ -471,14 +469,13 @@ var writeHandlerFile = async (ctx, { matchers, name }) => {
471
469
  await writeFile(
472
470
  join(handlerDirectory, `${handlerName}.js`),
473
471
  `
474
- import { decode as _base64Decode } from './edge-runtime/vendor/deno.land/std@0.175.0/encoding/base64.ts';
475
472
  import { init as htmlRewriterInit } from './edge-runtime/vendor/deno.land/x/htmlrewriter@v1.0.0/src/index.ts'
476
- import {handleMiddleware} from './edge-runtime/middleware.ts';
473
+ import { handleMiddleware } from './edge-runtime/middleware.ts';
477
474
  import handler from './server/${name}.js';
478
475
 
479
- await htmlRewriterInit({ module_or_path: _base64Decode(${JSON.stringify(
480
- htmlRewriterWasm.toString("base64")
481
- )}).buffer });
476
+ await htmlRewriterInit({ module_or_path: Uint8Array.from(${JSON.stringify([
477
+ ...htmlRewriterWasm
478
+ ])}) });
482
479
 
483
480
  export default (req, context) => handleMiddleware(req, context, handler);
484
481
  `
@@ -493,21 +490,9 @@ var copyHandlerDependencies = async (ctx, { name, files, wasm }) => {
493
490
  const parts = [shim];
494
491
  const outputFile = join(destDir, `server/${name}.js`);
495
492
  if (wasm?.length) {
496
- const base64ModulePath = join(
497
- destDir,
498
- "edge-runtime/vendor/deno.land/std@0.175.0/encoding/base64.ts"
499
- );
500
- const base64ModulePathRelativeToOutputFile = toPosixPath(
501
- relative(dirname(outputFile), base64ModulePath)
502
- );
503
- parts.push(`import { decode as _base64Decode } from "${base64ModulePathRelativeToOutputFile}";`);
504
493
  for (const wasmChunk of wasm ?? []) {
505
494
  const data = await readFile(join(srcDir, wasmChunk.filePath));
506
- parts.push(
507
- `const ${wasmChunk.name} = _base64Decode(${JSON.stringify(
508
- data.toString("base64")
509
- )}).buffer`
510
- );
495
+ parts.push(`const ${wasmChunk.name} = Uint8Array.from(${JSON.stringify([...data])})`);
511
496
  }
512
497
  }
513
498
  for (const file of files) {
@@ -19,7 +19,7 @@ var nextResponseProxy = (res, requestContext) => {
19
19
  requestContext.didPagesRouterOnDemandRevalidate = true;
20
20
  const result = originalValue.apply(target, args);
21
21
  if (result && isPromise(result)) {
22
- requestContext.trackBackgroundWork(result, "res.revalidate");
22
+ requestContext.trackBackgroundWork(result);
23
23
  }
24
24
  return result;
25
25
  };
@@ -6,13 +6,13 @@
6
6
 
7
7
  import {
8
8
  getTracer
9
- } from "./chunk-PG4KVN6X.js";
10
- import {
11
- getRequestContext
12
- } from "./chunk-FB56KFLR.js";
9
+ } from "./chunk-NEZW7TGG.js";
13
10
  import {
14
11
  getRegionalBlobStore
15
12
  } from "./chunk-K4RDUZYO.js";
13
+ import {
14
+ getRequestContext
15
+ } from "./chunk-LVXJQ2G2.js";
16
16
  import "./chunk-5QSXBV7L.js";
17
17
  import "./chunk-GNGHTHMQ.js";
18
18
  import {
@@ -490,10 +490,7 @@ ResponseCache.prototype.get = function get(...getArgs) {
490
490
  const workPromise = fn(...workFnArgs);
491
491
  const requestContext = getRequestContext();
492
492
  if (requestContext && workPromise instanceof Promise) {
493
- requestContext.trackBackgroundWork(
494
- workPromise,
495
- `responseCache batcher ${JSON.stringify(key)}`
496
- );
493
+ requestContext.trackBackgroundWork(workPromise);
497
494
  }
498
495
  return await workPromise;
499
496
  };
@@ -508,10 +505,7 @@ ResponseCache.prototype.get = function get(...getArgs) {
508
505
  const workPromise = new Promise((_resolve) => {
509
506
  backgroundWork.set(key, _resolve);
510
507
  });
511
- requestContext.trackBackgroundWork(
512
- workPromise,
513
- `responseCache pendingResponses ${JSON.stringify(key)}`
514
- );
508
+ requestContext.trackBackgroundWork(workPromise);
515
509
  }
516
510
  return originalPendingResponsesSet.call(this.pendingResponses, key, value);
517
511
  };
@@ -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.9.3-background-debug-logs.0";
11
+ var version = "5.9.4";
12
12
  var description = "Run Next.js seamlessly on Netlify";
13
13
  var main = "./dist/index.js";
14
14
  var type = "module";
package/dist/index.js CHANGED
@@ -6,18 +6,19 @@
6
6
 
7
7
  import {
8
8
  copyPrerenderedContent
9
- } from "./esm-chunks/chunk-J4D25YDX.js";
9
+ } from "./esm-chunks/chunk-BVYZSEV6.js";
10
10
  import {
11
11
  copyStaticAssets,
12
12
  copyStaticContent,
13
13
  copyStaticExport,
14
14
  publishStaticDir,
15
15
  unpublishStaticDir
16
- } from "./esm-chunks/chunk-NTLBFRPA.js";
16
+ } from "./esm-chunks/chunk-HWMLYAVP.js";
17
+ import "./esm-chunks/chunk-TYCYFZ22.js";
17
18
  import {
18
19
  clearStaleEdgeHandlers,
19
20
  createEdgeHandlers
20
- } from "./esm-chunks/chunk-HGXG447M.js";
21
+ } from "./esm-chunks/chunk-OAVVYSTW.js";
21
22
  import {
22
23
  clearStaleServerHandlers,
23
24
  createServerHandler
@@ -48,7 +49,6 @@ import {
48
49
  import "./esm-chunks/chunk-KGYJQ2U2.js";
49
50
  import "./esm-chunks/chunk-ZENB67PD.js";
50
51
  import "./esm-chunks/chunk-APO262HE.js";
51
- import "./esm-chunks/chunk-TYCYFZ22.js";
52
52
  import "./esm-chunks/chunk-UYKENJEU.js";
53
53
  import "./esm-chunks/chunk-OEQOKJGE.js";
54
54
 
@@ -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.9.3-background-debug-logs.0";
206
+ var version = "5.9.4";
207
207
 
208
208
  // src/shared/cache-types.cts
209
209
  var isCachedPageValue = (value) => value.kind === "PAGE" || value.kind === "PAGES";
@@ -2022,8 +2022,7 @@ var NetlifyCacheHandler = class {
2022
2022
  requestContext.trackBackgroundWork(
2023
2023
  purgeCache({ tags, userAgent: purgeCacheUserAgent }).catch((error) => {
2024
2024
  getLogger().withError(error).error(`[NetlifyCacheHandler]: Purging the cache for tag ${tag} failed`);
2025
- }),
2026
- `cdn purge after page router .revalidate ${tag}`
2025
+ })
2027
2026
  );
2028
2027
  }
2029
2028
  }
@@ -2034,10 +2033,7 @@ var NetlifyCacheHandler = class {
2034
2033
  const revalidateTagPromise = this.doRevalidateTag(tagOrTags, ...args);
2035
2034
  const requestContext = getRequestContext();
2036
2035
  if (requestContext) {
2037
- requestContext.trackBackgroundWork(
2038
- revalidateTagPromise,
2039
- `revalidateTag ${JSON.stringify(tagOrTags)}`
2040
- );
2036
+ requestContext.trackBackgroundWork(revalidateTagPromise);
2041
2037
  }
2042
2038
  return revalidateTagPromise;
2043
2039
  }
@@ -123,22 +123,13 @@ init_internal();
123
123
  // src/run/handlers/request-context.cts
124
124
  function createRequestContext(request, context) {
125
125
  const backgroundWorkPromises = [];
126
- let backgroundWorkCounter = 0;
127
126
  return {
128
127
  captureServerTiming: request?.headers.has("x-next-debug-logging") ?? false,
129
- trackBackgroundWork: (promise, description) => {
130
- backgroundWorkCounter += 1;
131
- const counter = backgroundWorkCounter;
132
- const label = `background #${counter} - ${description ?? "unknown"} - ${context?.requestId}`;
133
- const start = Date.now();
134
- console.log(`Start ${label}`);
135
- const trackedPromise = promise.finally(() => {
136
- console.log(`End ${label} - ${(Date.now() - start) / 1e3}s`);
137
- });
128
+ trackBackgroundWork: (promise) => {
138
129
  if (context?.waitUntil) {
139
- context.waitUntil(trackedPromise);
130
+ context.waitUntil(promise);
140
131
  } else {
141
- backgroundWorkPromises.push(trackedPromise);
132
+ backgroundWorkPromises.push(promise);
142
133
  }
143
134
  },
144
135
  get backgroundWorkPromise() {
@@ -6,26 +6,26 @@
6
6
 
7
7
  import {
8
8
  getTracer
9
- } from "../../esm-chunks/chunk-PG4KVN6X.js";
10
- import {
11
- createRequestContext,
12
- getLogger,
13
- getRequestContext
14
- } from "../../esm-chunks/chunk-FB56KFLR.js";
9
+ } from "../../esm-chunks/chunk-NEZW7TGG.js";
15
10
  import {
16
11
  adjustDateHeader,
17
12
  setCacheControlHeaders,
18
13
  setCacheStatusHeader,
19
14
  setCacheTagsHeaders,
20
15
  setVaryHeaders
21
- } from "../../esm-chunks/chunk-BEIUVQZK.js";
16
+ } from "../../esm-chunks/chunk-G3TOKXOX.js";
22
17
  import "../../esm-chunks/chunk-K4RDUZYO.js";
18
+ import {
19
+ createRequestContext,
20
+ getLogger,
21
+ getRequestContext
22
+ } from "../../esm-chunks/chunk-LVXJQ2G2.js";
23
23
  import {
24
24
  nextResponseProxy
25
- } from "../../esm-chunks/chunk-5N54G5SN.js";
25
+ } from "../../esm-chunks/chunk-XS27YRA5.js";
26
+ import "../../esm-chunks/chunk-TYCYFZ22.js";
26
27
  import "../../esm-chunks/chunk-5QSXBV7L.js";
27
28
  import "../../esm-chunks/chunk-GNGHTHMQ.js";
28
- import "../../esm-chunks/chunk-TYCYFZ22.js";
29
29
  import {
30
30
  __commonJS,
31
31
  __toESM
@@ -3118,16 +3118,13 @@ function setupWaitUntil() {
3118
3118
  ;
3119
3119
  globalThis[NEXT_REQUEST_CONTEXT_SYMBOL] = {
3120
3120
  get() {
3121
- const trackBackgroundWork = getRequestContext()?.trackBackgroundWork;
3122
- return {
3123
- waitUntil: trackBackgroundWork ? (promise) => trackBackgroundWork(promise, "after()") : void 0
3124
- };
3121
+ return { waitUntil: getRequestContext()?.trackBackgroundWork };
3125
3122
  }
3126
3123
  };
3127
3124
  }
3128
3125
 
3129
3126
  // src/run/handlers/server.ts
3130
- var nextImportPromise = import("../../esm-chunks/next-FWMVEHSM.js");
3127
+ var nextImportPromise = import("../../esm-chunks/next-37W7QRMR.js");
3131
3128
  setupWaitUntil();
3132
3129
  var nextHandler;
3133
3130
  var nextConfig;
@@ -3144,10 +3141,7 @@ var disableFaultyTransferEncodingHandling = (res) => {
3144
3141
  return originalStoreHeader.call(this, firstLine, headers);
3145
3142
  };
3146
3143
  };
3147
- var server_default = async (request, context) => {
3148
- const label = `response - ${request.url} - ${context.requestId}`;
3149
- const start = Date.now();
3150
- console.log(`Start ${label}`);
3144
+ var server_default = async (request) => {
3151
3145
  const tracer = getTracer();
3152
3146
  if (!nextHandler) {
3153
3147
  await tracer.withActiveSpan("initialize next server", async () => {
@@ -3191,22 +3185,23 @@ var server_default = async (request, context) => {
3191
3185
  span.setAttribute("responseCacheKey", requestContext.responseCacheKey);
3192
3186
  }
3193
3187
  await adjustDateHeader({ headers: response.headers, request, span, tracer, requestContext });
3194
- setCacheControlHeaders(response, request, requestContext);
3188
+ setCacheControlHeaders(response, request, requestContext, nextConfig);
3195
3189
  setCacheTagsHeaders(response.headers, requestContext);
3196
3190
  setVaryHeaders(response.headers, request, nextConfig);
3197
3191
  setCacheStatusHeader(response.headers);
3198
- if (response.status > 300 && response.status < 400 || response.status >= 500) {
3199
- const body = await response.text();
3200
- return new Response(body || null, response);
3192
+ async function waitForBackgroundWork() {
3193
+ await nextHandlerPromise;
3194
+ res.emit("close");
3195
+ await requestContext.backgroundWorkPromise;
3201
3196
  }
3202
3197
  const keepOpenUntilNextFullyRendered = new TransformStream({
3203
3198
  async flush() {
3204
- await nextHandlerPromise;
3205
- console.log(`End ${label} - ${(Date.now() - start) / 1e3}s`);
3206
- res.emit("close");
3207
- await requestContext.backgroundWorkPromise;
3199
+ await waitForBackgroundWork();
3208
3200
  }
3209
3201
  });
3202
+ if (!response.body) {
3203
+ await waitForBackgroundWork();
3204
+ }
3210
3205
  return new Response(response.body?.pipeThrough(keepOpenUntilNextFullyRendered), response);
3211
3206
  });
3212
3207
  };
@@ -6,7 +6,7 @@
6
6
 
7
7
  import {
8
8
  getLogger
9
- } from "../../esm-chunks/chunk-FB56KFLR.js";
9
+ } from "../../esm-chunks/chunk-LVXJQ2G2.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-W4QAAZFL.js");
68871
+ } = await import("../../esm-chunks/package-AJQOUMDK.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,
@@ -143,10 +143,7 @@ function setupWaitUntil() {
143
143
  ;
144
144
  globalThis[NEXT_REQUEST_CONTEXT_SYMBOL] = {
145
145
  get() {
146
- const trackBackgroundWork = getRequestContext()?.trackBackgroundWork;
147
- return {
148
- waitUntil: trackBackgroundWork ? (promise) => trackBackgroundWork(promise, "after()") : void 0
149
- };
146
+ return { waitUntil: getRequestContext()?.trackBackgroundWork };
150
147
  }
151
148
  };
152
149
  }
@@ -10,8 +10,9 @@ import {
10
10
  setCacheStatusHeader,
11
11
  setCacheTagsHeaders,
12
12
  setVaryHeaders
13
- } from "../esm-chunks/chunk-BEIUVQZK.js";
13
+ } from "../esm-chunks/chunk-G3TOKXOX.js";
14
14
  import "../esm-chunks/chunk-K4RDUZYO.js";
15
+ import "../esm-chunks/chunk-LVXJQ2G2.js";
15
16
  import "../esm-chunks/chunk-TYCYFZ22.js";
16
17
  import "../esm-chunks/chunk-OEQOKJGE.js";
17
18
  export {
package/dist/run/next.cjs CHANGED
@@ -2119,10 +2119,7 @@ ResponseCache.prototype.get = function get(...getArgs) {
2119
2119
  const workPromise = fn(...workFnArgs);
2120
2120
  const requestContext = getRequestContext();
2121
2121
  if (requestContext && workPromise instanceof Promise) {
2122
- requestContext.trackBackgroundWork(
2123
- workPromise,
2124
- `responseCache batcher ${JSON.stringify(key)}`
2125
- );
2122
+ requestContext.trackBackgroundWork(workPromise);
2126
2123
  }
2127
2124
  return await workPromise;
2128
2125
  };
@@ -2137,10 +2134,7 @@ ResponseCache.prototype.get = function get(...getArgs) {
2137
2134
  const workPromise = new Promise((_resolve) => {
2138
2135
  backgroundWork.set(key, _resolve);
2139
2136
  });
2140
- requestContext.trackBackgroundWork(
2141
- workPromise,
2142
- `responseCache pendingResponses ${JSON.stringify(key)}`
2143
- );
2137
+ requestContext.trackBackgroundWork(workPromise);
2144
2138
  }
2145
2139
  return originalPendingResponsesSet.call(this.pendingResponses, key, value);
2146
2140
  };
@@ -6,7 +6,7 @@
6
6
 
7
7
  import {
8
8
  nextResponseProxy
9
- } from "../esm-chunks/chunk-5N54G5SN.js";
9
+ } from "../esm-chunks/chunk-XS27YRA5.js";
10
10
  import "../esm-chunks/chunk-OEQOKJGE.js";
11
11
  export {
12
12
  nextResponseProxy
@@ -14,6 +14,8 @@ import {
14
14
  normalizeLocalePath,
15
15
  normalizeTrailingSlash,
16
16
  relativizeURL,
17
+ removeBasePath,
18
+ rewriteDataPath,
17
19
  } from './util.ts'
18
20
 
19
21
  export interface FetchEventResult {
@@ -180,14 +182,16 @@ export const buildResponse = async ({
180
182
  }
181
183
 
182
184
  if (isDataReq) {
183
- // The rewrite target is a data request, but a middleware rewrite target is always for the page route,
184
- // so we need to tell the server this is a data request. Setting the `x-nextjs-data` header is not enough. 🤷
185
- rewriteUrl.searchParams.set('__nextDataReq', '1')
185
+ rewriteUrl.pathname = rewriteDataPath({
186
+ dataUrl: new URL(request.url).pathname,
187
+ newRoute: removeBasePath(rewriteUrl.pathname, nextConfig?.basePath),
188
+ basePath: nextConfig?.basePath,
189
+ })
190
+ } else {
191
+ // respect trailing slash rules to prevent 308s
192
+ rewriteUrl.pathname = normalizeTrailingSlash(rewriteUrl.pathname, nextConfig?.trailingSlash)
186
193
  }
187
194
 
188
- // respect trailing slash rules to prevent 308s
189
- rewriteUrl.pathname = normalizeTrailingSlash(rewriteUrl.pathname, nextConfig?.trailingSlash)
190
-
191
195
  const target = normalizeLocalizedTarget({ target: rewriteUrl.toString(), request, nextConfig })
192
196
  if (target === request.url) {
193
197
  logger.withFields({ rewrite_url: rewrite }).debug('Rewrite url is same as original url')
@@ -2,7 +2,6 @@
2
2
  // It acts as a seed that populates the `vendor/` directory and should not be
3
3
  // imported directly.
4
4
 
5
- import 'https://deno.land/std@0.175.0/encoding/base64.ts'
6
5
  import 'https://deno.land/std@0.175.0/http/cookie.ts'
7
6
  import 'https://deno.land/std@0.175.0/node/buffer.ts'
8
7
  import 'https://deno.land/std@0.175.0/node/events.ts'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/plugin-nextjs",
3
- "version": "5.9.3-background-debug-logs.0",
3
+ "version": "5.9.4",
4
4
  "description": "Run Next.js seamlessly on Netlify",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -4,6 +4,9 @@
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
+ import {
8
+ encodeBlobKey
9
+ } from "./chunk-TYCYFZ22.js";
7
10
  import {
8
11
  wrapTracer
9
12
  } from "./chunk-5QSXBV7L.js";
@@ -20,9 +23,6 @@ import {
20
23
  import {
21
24
  require_semver
22
25
  } 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";
@@ -4,6 +4,9 @@
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
+ import {
8
+ encodeBlobKey
9
+ } from "./chunk-TYCYFZ22.js";
7
10
  import {
8
11
  wrapTracer
9
12
  } from "./chunk-5QSXBV7L.js";
@@ -17,9 +20,6 @@ import {
17
20
  import {
18
21
  require_out
19
22
  } 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";