@sveltejs/adapter-vercel 5.10.1 → 5.10.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/files/edge.js +26 -2
- package/package.json +2 -2
package/files/edge.js
CHANGED
|
@@ -5,6 +5,14 @@ import { manifest } from 'MANIFEST';
|
|
|
5
5
|
|
|
6
6
|
const server = new Server(manifest);
|
|
7
7
|
|
|
8
|
+
/** @type {HeadersInit | undefined} */
|
|
9
|
+
let read_headers;
|
|
10
|
+
if (process.env.VERCEL_AUTOMATION_BYPASS_SECRET) {
|
|
11
|
+
read_headers = {
|
|
12
|
+
'x-vercel-protection-bypass': process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
/**
|
|
9
17
|
* We don't know the origin until we receive a request, but
|
|
10
18
|
* that's guaranteed to happen before we call `read`
|
|
@@ -15,10 +23,26 @@ let origin;
|
|
|
15
23
|
const initialized = server.init({
|
|
16
24
|
env: /** @type {Record<string, string>} */ (process.env),
|
|
17
25
|
read: async (file) => {
|
|
18
|
-
const
|
|
26
|
+
const url = `${origin}/${file}`;
|
|
27
|
+
const response = await fetch(url, {
|
|
28
|
+
// we need to add a bypass header if the user has deployment protection enabled
|
|
29
|
+
// see https://vercel.com/docs/deployment-protection/methods-to-bypass-deployment-protection/protection-bypass-automation
|
|
30
|
+
headers: read_headers
|
|
31
|
+
});
|
|
32
|
+
|
|
19
33
|
if (!response.ok) {
|
|
20
|
-
|
|
34
|
+
if (response.status === 401) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Please enable Protection Bypass for Automation: https://svelte.dev/docs/kit/adapter-vercel#Troubleshooting-Deployment-protection`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// belt and braces — not sure how we could end up here
|
|
41
|
+
throw new Error(
|
|
42
|
+
`read(...) failed: could not fetch ${url} (${response.status} ${response.statusText})`
|
|
43
|
+
);
|
|
21
44
|
}
|
|
45
|
+
|
|
22
46
|
return response.body;
|
|
23
47
|
}
|
|
24
48
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/adapter-vercel",
|
|
3
|
-
"version": "5.10.
|
|
3
|
+
"version": "5.10.2",
|
|
4
4
|
"description": "A SvelteKit adapter that creates a Vercel app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adapter",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@types/node": "^18.19.119",
|
|
43
43
|
"typescript": "^5.3.3",
|
|
44
44
|
"vitest": "^3.2.3",
|
|
45
|
-
"@sveltejs/kit": "^2.33.
|
|
45
|
+
"@sveltejs/kit": "^2.33.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@sveltejs/kit": "^2.4.0"
|