@vercel/node 2.9.13 → 2.9.14

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.
@@ -2,9 +2,18 @@
2
2
  /* global addEventListener */
3
3
 
4
4
  function buildUrl(requestDetails) {
5
- let proto = requestDetails.headers['x-forwarded-proto'].split(/\b/).shift(); // handling multi-protocol like https,http://...
6
- let host = requestDetails.headers['x-forwarded-host'];
7
- let path = requestDetails.url;
5
+ const host = requestDetails.headers['x-forwarded-host'] || '127.0.0.1';
6
+ const path = requestDetails.url || '/';
7
+
8
+ const allProtocols = requestDetails.headers['x-forwarded-proto'];
9
+ let proto;
10
+ if (allProtocols) {
11
+ // handle multi-protocol like: https,http://...
12
+ proto = allProtocols.split(/\b/).shift();
13
+ } else {
14
+ proto = 'http';
15
+ }
16
+
8
17
  return `${proto}://${host}${path}`;
9
18
  }
10
19
 
@@ -16,7 +25,7 @@ async function respond(
16
25
  dependencies
17
26
  ) {
18
27
  const { Request, Response } = dependencies;
19
- const { isMiddleware, entrypointLabel } = options;
28
+ const { isMiddleware } = options;
20
29
 
21
30
  let body;
22
31
 
@@ -26,7 +35,7 @@ async function respond(
26
35
  }
27
36
  }
28
37
 
29
- let request = new Request(buildUrl(requestDetails), {
38
+ const request = new Request(buildUrl(requestDetails), {
30
39
  headers: requestDetails.headers,
31
40
  method: requestDetails.method,
32
41
  body: body,
@@ -45,9 +54,7 @@ async function respond(
45
54
  },
46
55
  });
47
56
  } else {
48
- throw new Error(
49
- `Edge Function "${entrypointLabel}" did not return a response.`
50
- );
57
+ throw new Error(`Edge Function did not return a response.`);
51
58
  }
52
59
  }
53
60
  return response;
@@ -68,8 +75,8 @@ function toResponseError(error, Response) {
68
75
  }
69
76
 
70
77
  async function parseRequestEvent(event) {
71
- let serializedRequest = await event.request.text();
72
- let requestDetails = JSON.parse(serializedRequest);
78
+ const serializedRequest = await event.request.text();
79
+ const requestDetails = JSON.parse(serializedRequest);
73
80
  return requestDetails;
74
81
  }
75
82
 
@@ -78,8 +85,8 @@ async function parseRequestEvent(event) {
78
85
  function registerFetchListener(userEdgeHandler, options, dependencies) {
79
86
  addEventListener('fetch', async event => {
80
87
  try {
81
- let requestDetails = await parseRequestEvent(event);
82
- let response = await respond(
88
+ const requestDetails = await parseRequestEvent(event);
89
+ const response = await respond(
83
90
  userEdgeHandler,
84
91
  requestDetails,
85
92
  event,
package/dist/index.js CHANGED
@@ -302075,7 +302075,9 @@ async function compile(workPath, baseDir, entrypointPath, config, nodeVersion, i
302075
302075
  shouldAddSourcemapSupport = true;
302076
302076
  return source;
302077
302077
  }
302078
- const conditions = isEdgeFunction ? ['worker', 'browser'] : undefined;
302078
+ const conditions = isEdgeFunction
302079
+ ? ['edge-light', 'browser', 'module', 'import', 'require']
302080
+ : undefined;
302079
302081
  const { fileList, esmFileList, warnings } = await nft_1.nodeFileTrace([...inputFiles], {
302080
302082
  base: baseDir,
302081
302083
  processCwd: workPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/node",
3
- "version": "2.9.13",
3
+ "version": "2.9.14",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "@edge-runtime/vm": "2.0.0",
33
33
  "@types/node": "14.18.33",
34
- "@vercel/build-utils": "6.4.0",
34
+ "@vercel/build-utils": "6.5.0",
35
35
  "@vercel/node-bridge": "3.1.14",
36
36
  "@vercel/static-config": "2.0.14",
37
37
  "edge-runtime": "2.0.0",
@@ -64,5 +64,5 @@
64
64
  "test-listen": "1.1.0",
65
65
  "ts-morph": "12.0.0"
66
66
  },
67
- "gitHead": "b2c68f1301b6a5eb41b6261b7faac6a8fa4c53eb"
67
+ "gitHead": "ab9915af32e54338845f6ff32340dd0189474c55"
68
68
  }