@sveltejs/adapter-vercel 5.10.0 → 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 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 response = await fetch(`${origin}/${file}`);
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
- throw new Error(`Failed to fetch ${file}: ${response.status} ${response.statusText}`);
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/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export interface ServerlessConfig {
7
7
  /**
8
8
  * Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs18.x'`, `'nodejs20.x'` etc).
9
9
  * @default Same as the build environment
10
+ * @deprecated
10
11
  */
11
12
  runtime?: `nodejs${number}.x`;
12
13
  /**
@@ -74,6 +75,7 @@ type ImagesConfig = {
74
75
  contentDispositionType?: string;
75
76
  };
76
77
 
78
+ /** @deprecated */
77
79
  export interface EdgeConfig {
78
80
  /**
79
81
  * Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs18.x'`, `'nodejs20.x'` etc).
package/index.js CHANGED
@@ -131,12 +131,21 @@ const plugin = function (defaults = {}) {
131
131
  }
132
132
  }
133
133
 
134
+ let warned = false;
135
+
134
136
  /**
135
137
  * @param {string} name
136
138
  * @param {import('./index.js').EdgeConfig} config
137
139
  * @param {import('@sveltejs/kit').RouteDefinition<import('./index.js').EdgeConfig>[]} routes
138
140
  */
139
141
  async function generate_edge_function(name, config, routes) {
142
+ if (!warned) {
143
+ warned = true;
144
+ builder.log.warn(
145
+ `The \`runtime: 'edge'\` option is deprecated, and will be removed in a future version of adapter-vercel`
146
+ );
147
+ }
148
+
140
149
  const tmp = builder.getBuildDirectory(`vercel-tmp/${name}`);
141
150
  const relativePath = path.posix.relative(tmp, builder.getServerDirectory());
142
151
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/adapter-vercel",
3
- "version": "5.10.0",
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.32.0"
45
+ "@sveltejs/kit": "^2.33.1"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@sveltejs/kit": "^2.4.0"