@netlify/plugin-nextjs 5.2.1 → 5.2.2
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/templates/handler-monorepo.tmpl.js +1 -3
- package/dist/build/templates/handler.tmpl.js +1 -3
- package/dist/esm-chunks/{package-SCUAWNXR.js → package-YOCAX5OR.js} +5 -5
- package/dist/run/handlers/cache.cjs +72 -226
- package/dist/run/handlers/tracing.js +1 -1
- package/dist/run/headers.js +1 -1
- package/dist/run/systemlog.js +67 -96
- package/edge-runtime/lib/response.ts +6 -3
- package/package.json +1 -1
|
@@ -16,9 +16,7 @@ export default async function (req, context) {
|
|
|
16
16
|
tracing.start()
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const requestContext = createRequestContext(
|
|
20
|
-
req.headers.get('x-nf-debug-logging') || req.headers.get('x-next-debug-logging'),
|
|
21
|
-
)
|
|
19
|
+
const requestContext = createRequestContext(req.headers.get('x-next-debug-logging'))
|
|
22
20
|
const tracer = getTracer()
|
|
23
21
|
|
|
24
22
|
const handlerResponse = await runWithRequestContext(requestContext, () => {
|
|
@@ -13,9 +13,7 @@ export default async function handler(req, context) {
|
|
|
13
13
|
if (process.env.NETLIFY_OTLP_TRACE_EXPORTER_URL) {
|
|
14
14
|
tracing.start()
|
|
15
15
|
}
|
|
16
|
-
const requestContext = createRequestContext(
|
|
17
|
-
req.headers.get('x-nf-debug-logging') || req.headers.get('x-next-debug-logging'),
|
|
18
|
-
)
|
|
16
|
+
const requestContext = createRequestContext(req.headers.get('x-next-debug-logging'))
|
|
19
17
|
const tracer = getTracer()
|
|
20
18
|
|
|
21
19
|
const handlerResponse = await runWithRequestContext(requestContext, () => {
|
|
@@ -8,7 +8,7 @@ import "./chunk-5JVNISGM.js";
|
|
|
8
8
|
|
|
9
9
|
// package.json
|
|
10
10
|
var name = "@netlify/plugin-nextjs";
|
|
11
|
-
var version = "5.2.
|
|
11
|
+
var version = "5.2.2";
|
|
12
12
|
var description = "Run Next.js seamlessly on Netlify";
|
|
13
13
|
var main = "./dist/index.js";
|
|
14
14
|
var type = "module";
|
|
@@ -60,11 +60,11 @@ var devDependencies = {
|
|
|
60
60
|
"@netlify/blobs": "^7.3.0",
|
|
61
61
|
"@netlify/build": "^29.41.2",
|
|
62
62
|
"@netlify/edge-bundler": "^12.0.0",
|
|
63
|
-
"@netlify/edge-functions": "^2.6.
|
|
63
|
+
"@netlify/edge-functions": "^2.6.1",
|
|
64
64
|
"@netlify/eslint-config-node": "^7.0.1",
|
|
65
|
-
"@netlify/functions": "^2.
|
|
66
|
-
"@netlify/serverless-functions-api": "^1.18.
|
|
67
|
-
"@netlify/zip-it-and-ship-it": "^9.32.
|
|
65
|
+
"@netlify/functions": "^2.6.3",
|
|
66
|
+
"@netlify/serverless-functions-api": "^1.18.1",
|
|
67
|
+
"@netlify/zip-it-and-ship-it": "^9.32.2",
|
|
68
68
|
"@opentelemetry/api": "^1.8.0",
|
|
69
69
|
"@opentelemetry/exporter-trace-otlp-http": "^0.51.0",
|
|
70
70
|
"@opentelemetry/resources": "^1.24.0",
|
|
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
8
|
var __export = (target, all) => {
|
|
12
9
|
for (var name in all)
|
|
13
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,230 +27,71 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
27
|
));
|
|
31
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
29
|
|
|
33
|
-
//
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
function isPromise(obj) {
|
|
39
|
-
return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// node_modules/@netlify/functions/dist/lib/consts.js
|
|
45
|
-
var require_consts = __commonJS({
|
|
46
|
-
"node_modules/@netlify/functions/dist/lib/consts.js"(exports2) {
|
|
47
|
-
"use strict";
|
|
48
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
49
|
-
exports2.METADATA_VERSION = exports2.HTTP_STATUS_OK = exports2.HTTP_STATUS_METHOD_NOT_ALLOWED = exports2.BUILDER_FUNCTIONS_FLAG = void 0;
|
|
50
|
-
var BUILDER_FUNCTIONS_FLAG = true;
|
|
51
|
-
exports2.BUILDER_FUNCTIONS_FLAG = BUILDER_FUNCTIONS_FLAG;
|
|
52
|
-
var HTTP_STATUS_METHOD_NOT_ALLOWED = 405;
|
|
53
|
-
exports2.HTTP_STATUS_METHOD_NOT_ALLOWED = HTTP_STATUS_METHOD_NOT_ALLOWED;
|
|
54
|
-
var HTTP_STATUS_OK = 200;
|
|
55
|
-
exports2.HTTP_STATUS_OK = HTTP_STATUS_OK;
|
|
56
|
-
var METADATA_VERSION = 1;
|
|
57
|
-
exports2.METADATA_VERSION = METADATA_VERSION;
|
|
58
|
-
}
|
|
30
|
+
// src/run/handlers/cache.cts
|
|
31
|
+
var cache_exports = {};
|
|
32
|
+
__export(cache_exports, {
|
|
33
|
+
NetlifyCacheHandler: () => NetlifyCacheHandler,
|
|
34
|
+
default: () => cache_default
|
|
59
35
|
});
|
|
36
|
+
module.exports = __toCommonJS(cache_exports);
|
|
37
|
+
var import_node_buffer = require("node:buffer");
|
|
60
38
|
|
|
61
|
-
// node_modules/@netlify/functions/dist/
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
};
|
|
68
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
69
|
-
exports2.builder = void 0;
|
|
70
|
-
var is_promise_1 = __importDefault(require_is_promise());
|
|
71
|
-
var consts_js_1 = require_consts();
|
|
72
|
-
var augmentResponse = (response) => {
|
|
73
|
-
if (!response) {
|
|
74
|
-
return response;
|
|
75
|
-
}
|
|
76
|
-
const metadata = { version: consts_js_1.METADATA_VERSION, builder_function: consts_js_1.BUILDER_FUNCTIONS_FLAG, ttl: response.ttl || 0 };
|
|
77
|
-
return {
|
|
78
|
-
...response,
|
|
79
|
-
metadata
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
var wrapHandler = (handler) => (
|
|
83
|
-
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
84
|
-
(event, context, callback) => {
|
|
85
|
-
if (event.httpMethod !== "GET" && event.httpMethod !== "HEAD") {
|
|
86
|
-
return Promise.resolve({
|
|
87
|
-
body: "Method Not Allowed",
|
|
88
|
-
statusCode: consts_js_1.HTTP_STATUS_METHOD_NOT_ALLOWED
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
const modifiedEvent = {
|
|
92
|
-
...event,
|
|
93
|
-
multiValueQueryStringParameters: {},
|
|
94
|
-
queryStringParameters: {}
|
|
95
|
-
};
|
|
96
|
-
const wrappedCallback = (error, response) => (
|
|
97
|
-
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
98
|
-
callback ? callback(error, augmentResponse(response)) : null
|
|
99
|
-
);
|
|
100
|
-
const execution = handler(modifiedEvent, context, wrappedCallback);
|
|
101
|
-
if ((0, is_promise_1.default)(execution)) {
|
|
102
|
-
return execution.then(augmentResponse);
|
|
103
|
-
}
|
|
104
|
-
return execution;
|
|
105
|
-
}
|
|
39
|
+
// node_modules/@netlify/functions/dist/chunk-COIAWFHF.mjs
|
|
40
|
+
var import_process = require("process");
|
|
41
|
+
var purgeCache = async (options = {}) => {
|
|
42
|
+
if (globalThis.fetch === void 0) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
"`fetch` is not available. Please ensure you're using Node.js version 18.0.0 or above. Refer to https://ntl.fyi/functions-runtime for more information."
|
|
106
45
|
);
|
|
107
|
-
exports2.builder = wrapHandler;
|
|
108
46
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
var purgeCache2 = async (options = {}) => {
|
|
119
|
-
if (globalThis.fetch === void 0) {
|
|
120
|
-
throw new Error("`fetch` is not available. Please ensure you're using Node.js version 18.0.0 or above. Refer to https://ntl.fyi/functions-runtime for more information.");
|
|
121
|
-
}
|
|
122
|
-
const payload = {
|
|
123
|
-
cache_tags: options.tags,
|
|
124
|
-
deploy_alias: options.deployAlias
|
|
125
|
-
};
|
|
126
|
-
const token = process_1.env.NETLIFY_PURGE_API_TOKEN || options.token;
|
|
127
|
-
if ("siteSlug" in options) {
|
|
128
|
-
payload.site_slug = options.siteSlug;
|
|
129
|
-
} else if ("domain" in options) {
|
|
130
|
-
payload.domain = options.domain;
|
|
131
|
-
} else {
|
|
132
|
-
const siteID = options.siteID || process_1.env.SITE_ID;
|
|
133
|
-
if (!siteID) {
|
|
134
|
-
throw new Error("The Netlify site ID was not found in the execution environment. Please supply it manually using the `siteID` property.");
|
|
135
|
-
}
|
|
136
|
-
payload.site_id = siteID;
|
|
137
|
-
}
|
|
138
|
-
if (!token) {
|
|
139
|
-
throw new Error("The cache purge API token was not found in the execution environment. Please supply it manually using the `token` property.");
|
|
140
|
-
}
|
|
141
|
-
const apiURL = options.apiURL || "https://api.netlify.com";
|
|
142
|
-
const response = await fetch(`${apiURL}/api/v1/purge`, {
|
|
143
|
-
method: "POST",
|
|
144
|
-
headers: {
|
|
145
|
-
"Content-Type": "application/json; charset=utf8",
|
|
146
|
-
Authorization: `Bearer ${token}`
|
|
147
|
-
},
|
|
148
|
-
body: JSON.stringify(payload)
|
|
149
|
-
});
|
|
150
|
-
if (!response.ok) {
|
|
151
|
-
throw new Error(`Cache purge API call returned an unexpected status code: ${response.status}`);
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
exports2.purgeCache = purgeCache2;
|
|
47
|
+
const payload = {
|
|
48
|
+
cache_tags: options.tags,
|
|
49
|
+
deploy_alias: options.deployAlias
|
|
50
|
+
};
|
|
51
|
+
const token = import_process.env.NETLIFY_PURGE_API_TOKEN || options.token;
|
|
52
|
+
if (import_process.env.NETLIFY_LOCAL && !token) {
|
|
53
|
+
const scope = options.tags?.length ? ` for tags ${options.tags?.join(", ")}` : "";
|
|
54
|
+
console.log(`Skipping purgeCache${scope} in local development.`);
|
|
55
|
+
return;
|
|
155
56
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
57
|
+
if ("siteSlug" in options) {
|
|
58
|
+
payload.site_slug = options.siteSlug;
|
|
59
|
+
} else if ("domain" in options) {
|
|
60
|
+
payload.domain = options.domain;
|
|
61
|
+
} else {
|
|
62
|
+
const siteID = options.siteID || import_process.env.SITE_ID;
|
|
63
|
+
if (!siteID) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
"The Netlify site ID was not found in the execution environment. Please supply it manually using the `siteID` property."
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
payload.site_id = siteID;
|
|
166
69
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
"node_modules/@netlify/functions/dist/lib/stream.js"(exports2) {
|
|
172
|
-
"use strict";
|
|
173
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
174
|
-
exports2.stream = void 0;
|
|
175
|
-
var node_stream_1 = require("node:stream");
|
|
176
|
-
var node_util_1 = require("node:util");
|
|
177
|
-
var pipeline = (0, node_util_1.promisify)(node_stream_1.pipeline);
|
|
178
|
-
var stream = (handler) => awslambda.streamifyResponse(async (event, responseStream, context) => {
|
|
179
|
-
const { body, ...httpResponseMetadata } = await handler(event, context);
|
|
180
|
-
const responseBody = awslambda.HttpResponseStream.from(responseStream, httpResponseMetadata);
|
|
181
|
-
if (typeof body === "undefined") {
|
|
182
|
-
responseBody.end();
|
|
183
|
-
} else if (typeof body === "string") {
|
|
184
|
-
responseBody.write(body);
|
|
185
|
-
responseBody.end();
|
|
186
|
-
} else {
|
|
187
|
-
await pipeline(body, responseBody);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
exports2.stream = stream;
|
|
70
|
+
if (!token) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
"The cache purge API token was not found in the execution environment. Please supply it manually using the `token` property."
|
|
73
|
+
);
|
|
191
74
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
75
|
+
const apiURL = options.apiURL || "https://api.netlify.com";
|
|
76
|
+
const response = await fetch(`${apiURL}/api/v1/purge`, {
|
|
77
|
+
method: "POST",
|
|
78
|
+
headers: {
|
|
79
|
+
"Content-Type": "application/json; charset=utf8",
|
|
80
|
+
Authorization: `Bearer ${token}`
|
|
81
|
+
},
|
|
82
|
+
body: JSON.stringify(payload)
|
|
83
|
+
});
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
throw new Error(`Cache purge API call returned an unexpected status code: ${response.status}`);
|
|
199
86
|
}
|
|
200
|
-
}
|
|
87
|
+
};
|
|
201
88
|
|
|
202
|
-
// node_modules/@netlify/functions/dist/
|
|
203
|
-
var
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
207
|
-
if (k2 === void 0)
|
|
208
|
-
k2 = k;
|
|
209
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
210
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
211
|
-
desc = { enumerable: true, get: function() {
|
|
212
|
-
return m[k];
|
|
213
|
-
} };
|
|
214
|
-
}
|
|
215
|
-
Object.defineProperty(o, k2, desc);
|
|
216
|
-
} : function(o, m, k, k2) {
|
|
217
|
-
if (k2 === void 0)
|
|
218
|
-
k2 = k;
|
|
219
|
-
o[k2] = m[k];
|
|
220
|
-
});
|
|
221
|
-
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
222
|
-
for (var p in m)
|
|
223
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p))
|
|
224
|
-
__createBinding(exports3, m, p);
|
|
225
|
-
};
|
|
226
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
227
|
-
exports2.stream = exports2.schedule = exports2.purgeCache = exports2.builder = void 0;
|
|
228
|
-
var builder_js_1 = require_builder();
|
|
229
|
-
Object.defineProperty(exports2, "builder", { enumerable: true, get: function() {
|
|
230
|
-
return builder_js_1.builder;
|
|
231
|
-
} });
|
|
232
|
-
var purge_cache_js_1 = require_purge_cache();
|
|
233
|
-
Object.defineProperty(exports2, "purgeCache", { enumerable: true, get: function() {
|
|
234
|
-
return purge_cache_js_1.purgeCache;
|
|
235
|
-
} });
|
|
236
|
-
var schedule_js_1 = require_schedule();
|
|
237
|
-
Object.defineProperty(exports2, "schedule", { enumerable: true, get: function() {
|
|
238
|
-
return schedule_js_1.schedule;
|
|
239
|
-
} });
|
|
240
|
-
var stream_js_1 = require_stream();
|
|
241
|
-
Object.defineProperty(exports2, "stream", { enumerable: true, get: function() {
|
|
242
|
-
return stream_js_1.stream;
|
|
243
|
-
} });
|
|
244
|
-
__exportStar(require_function(), exports2);
|
|
245
|
-
}
|
|
246
|
-
});
|
|
89
|
+
// node_modules/@netlify/functions/dist/chunk-XSZVKDJB.mjs
|
|
90
|
+
var import_stream = require("stream");
|
|
91
|
+
var import_util = require("util");
|
|
92
|
+
var pipeline = (0, import_util.promisify)(import_stream.pipeline);
|
|
247
93
|
|
|
248
94
|
// src/run/handlers/cache.cts
|
|
249
|
-
var cache_exports = {};
|
|
250
|
-
__export(cache_exports, {
|
|
251
|
-
NetlifyCacheHandler: () => NetlifyCacheHandler,
|
|
252
|
-
default: () => cache_default
|
|
253
|
-
});
|
|
254
|
-
module.exports = __toCommonJS(cache_exports);
|
|
255
|
-
var import_node_buffer = require("node:buffer");
|
|
256
|
-
var import_functions = __toESM(require_main());
|
|
257
95
|
var import_constants = require("next/dist/lib/constants.js");
|
|
258
96
|
var import_regional_blob_store = require("../regional-blob-store.cjs");
|
|
259
97
|
var import_request_context = require("./request-context.cjs");
|
|
@@ -391,7 +229,7 @@ var NetlifyCacheHandler = class {
|
|
|
391
229
|
if (requestContext?.didPagesRouterOnDemandRevalidate) {
|
|
392
230
|
const tag = `_N_T_${key === "/index" ? "/" : key}`;
|
|
393
231
|
console.debug("Purging CDN cache for:", [tag]);
|
|
394
|
-
|
|
232
|
+
purgeCache({ tags: [tag] }).catch((error) => {
|
|
395
233
|
console.error(`[NetlifyCacheHandler]: Purging the cache for tag ${tag} failed`, error);
|
|
396
234
|
});
|
|
397
235
|
}
|
|
@@ -399,18 +237,26 @@ var NetlifyCacheHandler = class {
|
|
|
399
237
|
});
|
|
400
238
|
}
|
|
401
239
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
402
|
-
async revalidateTag(
|
|
403
|
-
console.debug("NetlifyCacheHandler.revalidateTag",
|
|
240
|
+
async revalidateTag(tagOrTags, ...args) {
|
|
241
|
+
console.debug("NetlifyCacheHandler.revalidateTag", tagOrTags, args);
|
|
242
|
+
const tags = Array.isArray(tagOrTags) ? tagOrTags : [tagOrTags];
|
|
404
243
|
const data = {
|
|
405
244
|
revalidatedAt: Date.now()
|
|
406
245
|
};
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
246
|
+
await Promise.all(
|
|
247
|
+
tags.map(async (tag) => {
|
|
248
|
+
try {
|
|
249
|
+
await this.blobStore.setJSON(await this.encodeBlobKey(tag), data);
|
|
250
|
+
} catch (error) {
|
|
251
|
+
console.warn(`Failed to update tag manifest for ${tag}`, error);
|
|
252
|
+
}
|
|
253
|
+
})
|
|
254
|
+
);
|
|
255
|
+
purgeCache({ tags }).catch((error) => {
|
|
256
|
+
console.error(
|
|
257
|
+
`[NetlifyCacheHandler]: Purging the cache for tags ${tags.join(", ")} failed`,
|
|
258
|
+
error
|
|
259
|
+
);
|
|
414
260
|
});
|
|
415
261
|
}
|
|
416
262
|
resetRequestCache() {
|
|
@@ -67768,7 +67768,7 @@ var import_sdk_trace_node = __toESM(require_src20(), 1);
|
|
|
67768
67768
|
var import_semantic_conventions = __toESM(require_src(), 1);
|
|
67769
67769
|
var {
|
|
67770
67770
|
default: { version, name }
|
|
67771
|
-
} = await import("../../esm-chunks/package-
|
|
67771
|
+
} = await import("../../esm-chunks/package-YOCAX5OR.js");
|
|
67772
67772
|
var sdk = new import_sdk_node.NodeSDK({
|
|
67773
67773
|
resource: new import_resources.Resource({
|
|
67774
67774
|
[import_semantic_conventions.SEMRESATTRS_SERVICE_NAME]: name,
|
package/dist/run/headers.js
CHANGED
|
@@ -58,7 +58,7 @@ var mapHeaderValues = (header, callback) => {
|
|
|
58
58
|
};
|
|
59
59
|
var setVaryHeaders = (headers, request, { basePath, i18n }) => {
|
|
60
60
|
const netlifyVaryValues = {
|
|
61
|
-
header: ["x-nextjs-data"],
|
|
61
|
+
header: ["x-nextjs-data", "x-next-debug-logging"],
|
|
62
62
|
language: [],
|
|
63
63
|
cookie: ["__prerender_bypass", "__next_preview_data"],
|
|
64
64
|
query: [],
|
package/dist/run/systemlog.js
CHANGED
|
@@ -4,104 +4,75 @@
|
|
|
4
4
|
return createRequire(import.meta.url);
|
|
5
5
|
})();
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
__commonJS,
|
|
9
|
-
__require,
|
|
10
|
-
__toESM
|
|
11
|
-
} from "../esm-chunks/chunk-5JVNISGM.js";
|
|
7
|
+
import "../esm-chunks/chunk-5JVNISGM.js";
|
|
12
8
|
|
|
13
|
-
// node_modules/@netlify/functions/dist/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
fields;
|
|
37
|
-
logLevel;
|
|
38
|
-
constructor(fields = {}, logLevel = LogLevel2.Log) {
|
|
39
|
-
this.fields = fields;
|
|
40
|
-
this.logLevel = logLevel;
|
|
41
|
-
}
|
|
42
|
-
doLog(logger, message) {
|
|
43
|
-
if (process_1.env.NETLIFY_DEV && !process_1.env.NETLIFY_ENABLE_SYSTEM_LOGGING) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
logger(systemLogTag, JSON.stringify({ msg: message, fields: this.fields }));
|
|
47
|
-
}
|
|
48
|
-
log(message) {
|
|
49
|
-
if (this.logLevel > LogLevel2.Log) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
this.doLog(console.log, message);
|
|
53
|
-
}
|
|
54
|
-
debug(message) {
|
|
55
|
-
if (this.logLevel > LogLevel2.Debug) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
this.doLog(console.debug, message);
|
|
59
|
-
}
|
|
60
|
-
error(message) {
|
|
61
|
-
if (this.logLevel > LogLevel2.Error) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
this.doLog(console.error, message);
|
|
65
|
-
}
|
|
66
|
-
withLogLevel(level) {
|
|
67
|
-
return new _SystemLogger(this.fields, level);
|
|
68
|
-
}
|
|
69
|
-
withFields(fields) {
|
|
70
|
-
return new _SystemLogger({
|
|
71
|
-
...this.fields,
|
|
72
|
-
...fields
|
|
73
|
-
}, this.logLevel);
|
|
74
|
-
}
|
|
75
|
-
withError(error) {
|
|
76
|
-
const fields = error instanceof Error ? serializeError(error) : { error };
|
|
77
|
-
return this.withFields(fields);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
exports.systemLogger = new SystemLogger();
|
|
9
|
+
// node_modules/@netlify/functions/dist/chunk-HYMERDCV.mjs
|
|
10
|
+
import { env } from "process";
|
|
11
|
+
var systemLogTag = "__nfSystemLog";
|
|
12
|
+
var serializeError = (error) => {
|
|
13
|
+
const cause = error?.cause instanceof Error ? serializeError(error.cause) : error.cause;
|
|
14
|
+
return {
|
|
15
|
+
error: error.message,
|
|
16
|
+
error_cause: cause,
|
|
17
|
+
error_stack: error.stack
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
21
|
+
LogLevel2[LogLevel2["Debug"] = 1] = "Debug";
|
|
22
|
+
LogLevel2[LogLevel2["Log"] = 2] = "Log";
|
|
23
|
+
LogLevel2[LogLevel2["Error"] = 3] = "Error";
|
|
24
|
+
return LogLevel2;
|
|
25
|
+
})(LogLevel || {});
|
|
26
|
+
var SystemLogger = class _SystemLogger {
|
|
27
|
+
fields;
|
|
28
|
+
logLevel;
|
|
29
|
+
constructor(fields = {}, logLevel = 2) {
|
|
30
|
+
this.fields = fields;
|
|
31
|
+
this.logLevel = logLevel;
|
|
81
32
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"use strict";
|
|
88
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89
|
-
exports.LogLevel = exports.systemLogger = void 0;
|
|
90
|
-
var system_logger_js_1 = require_system_logger();
|
|
91
|
-
Object.defineProperty(exports, "systemLogger", { enumerable: true, get: function() {
|
|
92
|
-
return system_logger_js_1.systemLogger;
|
|
93
|
-
} });
|
|
94
|
-
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function() {
|
|
95
|
-
return system_logger_js_1.LogLevel;
|
|
96
|
-
} });
|
|
33
|
+
doLog(logger, message) {
|
|
34
|
+
if (env.NETLIFY_DEV && !env.NETLIFY_ENABLE_SYSTEM_LOGGING) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
logger(systemLogTag, JSON.stringify({ msg: message, fields: this.fields }));
|
|
97
38
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
39
|
+
log(message) {
|
|
40
|
+
if (this.logLevel > 2) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this.doLog(console.log, message);
|
|
44
|
+
}
|
|
45
|
+
debug(message) {
|
|
46
|
+
if (this.logLevel > 1) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this.doLog(console.debug, message);
|
|
50
|
+
}
|
|
51
|
+
error(message) {
|
|
52
|
+
if (this.logLevel > 3) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.doLog(console.error, message);
|
|
56
|
+
}
|
|
57
|
+
withLogLevel(level) {
|
|
58
|
+
return new _SystemLogger(this.fields, level);
|
|
59
|
+
}
|
|
60
|
+
withFields(fields) {
|
|
61
|
+
return new _SystemLogger(
|
|
62
|
+
{
|
|
63
|
+
...this.fields,
|
|
64
|
+
...fields
|
|
65
|
+
},
|
|
66
|
+
this.logLevel
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
withError(error) {
|
|
70
|
+
const fields = error instanceof Error ? serializeError(error) : { error };
|
|
71
|
+
return this.withFields(fields);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var systemLogger = new SystemLogger();
|
|
104
75
|
export {
|
|
105
|
-
|
|
106
|
-
|
|
76
|
+
LogLevel,
|
|
77
|
+
systemLogger as logger
|
|
107
78
|
};
|
|
@@ -3,6 +3,8 @@ import { HTMLRewriter } from '../vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/
|
|
|
3
3
|
|
|
4
4
|
import { updateModifiedHeaders } from './headers.ts'
|
|
5
5
|
import type { StructuredLogger } from './logging.ts'
|
|
6
|
+
import { addMiddlewareHeaders, isMiddlewareRequest, isMiddlewareResponse } from './middleware.ts'
|
|
7
|
+
import { RequestData } from './next-request.ts'
|
|
6
8
|
import {
|
|
7
9
|
addBasePath,
|
|
8
10
|
normalizeDataUrl,
|
|
@@ -10,8 +12,6 @@ import {
|
|
|
10
12
|
normalizeTrailingSlash,
|
|
11
13
|
relativizeURL,
|
|
12
14
|
} from './util.ts'
|
|
13
|
-
import { addMiddlewareHeaders, isMiddlewareRequest, isMiddlewareResponse } from './middleware.ts'
|
|
14
|
-
import { RequestData } from './next-request.ts'
|
|
15
15
|
|
|
16
16
|
export interface FetchEventResult {
|
|
17
17
|
response: Response
|
|
@@ -182,8 +182,11 @@ export const buildResponse = async ({
|
|
|
182
182
|
// The rewrite target is a data request, but a middleware rewrite target is always for the page route,
|
|
183
183
|
// so we need to tell the server this is a data request. Setting the `x-nextjs-data` header is not enough. 🤷
|
|
184
184
|
rewriteUrl.searchParams.set('__nextDataReq', '1')
|
|
185
|
-
rewriteUrl.pathname = normalizeTrailingSlash(rewriteUrl.pathname, nextConfig?.trailingSlash)
|
|
186
185
|
}
|
|
186
|
+
|
|
187
|
+
// respect trailing slash rules to prevent 308s
|
|
188
|
+
rewriteUrl.pathname = normalizeTrailingSlash(rewriteUrl.pathname, nextConfig?.trailingSlash)
|
|
189
|
+
|
|
187
190
|
const target = normalizeLocalizedTarget({ target: rewriteUrl.toString(), request, nextConfig })
|
|
188
191
|
if (target === request.url) {
|
|
189
192
|
logger.withFields({ rewrite_url: rewrite }).debug('Rewrite url is same as original url')
|