@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
|
-
|
6
|
-
|
7
|
-
|
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
|
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
|
-
|
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
|
-
|
72
|
-
|
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
|
-
|
82
|
-
|
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
|
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.
|
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.
|
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": "
|
67
|
+
"gitHead": "ab9915af32e54338845f6ff32340dd0189474c55"
|
68
68
|
}
|