@vercel/node 5.7.6 → 5.7.7

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.
@@ -1,10 +1,10 @@
1
1
  //
2
2
  // Unified Lambda handler for bundled vanilla API routes.
3
- // All bundleable lambdas share this exact file (same handler digest).
3
+ // All bundleable lambdas share this handler (same handler digest).
4
4
  // It reads x-matched-path to determine which entrypoint to invoke.
5
5
  //
6
- // IMPORTANT: This file must remain entrypoint-agnostic. Do not embed
7
- // any path-specific constants. The x-matched-path header is set by
6
+ // At build time the builder replaces the VERCEL_ENTRYPOINT_PREFIX env lookup
7
+ // with the actual prefix string. The x-matched-path header is set by
8
8
  // route rules injected by the builder.
9
9
  //
10
10
  // This runs at Lambda runtime where the handler is invoked with (req, res).
@@ -35,6 +35,19 @@ const HTTP_METHODS = [
35
35
 
36
36
  const handlerCache = Object.create(null);
37
37
 
38
+ // At build time the builder replaces the token below with the actual prefix.
39
+ const entrypointPrefix = process.env.VERCEL_ENTRYPOINT_PREFIX;
40
+
41
+ function getEntrypointCandidates(entrypoint) {
42
+ const candidates = [entrypoint];
43
+
44
+ if (typeof entrypointPrefix === 'string' && entrypointPrefix) {
45
+ candidates.push(entrypointPrefix + '/' + entrypoint);
46
+ }
47
+
48
+ return candidates;
49
+ }
50
+
38
51
  /**
39
52
  * Resolve an extensionless entrypoint to an actual file path.
40
53
  * Tries common JS extensions in order, returning the first match.
@@ -240,7 +253,14 @@ module.exports = async (req, res) => {
240
253
  const entrypoint = matchedPath.replace(/^\//, '') || 'index';
241
254
 
242
255
  if (!handlerCache[entrypoint]) {
243
- const filePath = resolveEntrypoint(entrypoint);
256
+ let filePath = null;
257
+ for (const candidate of getEntrypointCandidates(entrypoint)) {
258
+ filePath = resolveEntrypoint(candidate);
259
+ if (filePath) {
260
+ break;
261
+ }
262
+ }
263
+
244
264
  if (!filePath) {
245
265
  res.statusCode = 404;
246
266
  res.end('No handler found for ' + entrypoint);
package/dist/index.js CHANGED
@@ -85119,8 +85119,15 @@ var build = async ({
85119
85119
  const enableBundling = process.env.VERCEL_API_FUNCTION_BUNDLING === "1" && config.zeroConfig === true && !isMiddleware && !isEdgeFunction;
85120
85120
  if (enableBundling) {
85121
85121
  const bundledHandlerName = "___vc_bundled_api_handler.js";
85122
- preparedFiles[bundledHandlerName] = new import_build_utils3.FileFsRef({
85123
- fsPath: (0, import_path3.join)((0, import_path3.dirname)(__filename), "bundling-handler.js")
85122
+ const entrypointPrefix = (0, import_path3.relative)(baseDir, workPath).split(import_path3.sep).join("/");
85123
+ preparedFiles[bundledHandlerName] = new import_build_utils3.FileBlob({
85124
+ data: (0, import_fs.readFileSync)(
85125
+ (0, import_path3.join)((0, import_path3.dirname)(__filename), "bundling-handler.js"),
85126
+ "utf8"
85127
+ ).replace(
85128
+ "process.env.VERCEL_ENTRYPOINT_PREFIX",
85129
+ JSON.stringify(entrypointPrefix)
85130
+ )
85124
85131
  });
85125
85132
  handler = bundledHandlerName;
85126
85133
  if (!bundlingRoutesEmitted) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/node",
3
- "version": "5.7.6",
3
+ "version": "5.7.7",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
@@ -32,9 +32,9 @@
32
32
  "tsx": "4.21.0",
33
33
  "typescript": "npm:typescript@5.9.3",
34
34
  "undici": "5.28.4",
35
- "@vercel/error-utils": "2.0.3",
35
+ "@vercel/build-utils": "13.17.0",
36
36
  "@vercel/static-config": "3.2.0",
37
- "@vercel/build-utils": "13.16.0"
37
+ "@vercel/error-utils": "2.0.3"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@babel/core": "7.24.4",