@sveltejs/adapter-vercel 5.9.1 → 5.10.0
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/serverless.js +19 -21
- package/package.json +2 -2
package/files/serverless.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { installPolyfills } from '@sveltejs/kit/node/polyfills';
|
|
2
|
-
import {
|
|
2
|
+
import { createReadableStream } from '@sveltejs/kit/node';
|
|
3
3
|
import { Server } from 'SERVER';
|
|
4
4
|
import { manifest } from 'MANIFEST';
|
|
5
5
|
import process from 'node:process';
|
|
@@ -15,33 +15,31 @@ await server.init({
|
|
|
15
15
|
|
|
16
16
|
const DATA_SUFFIX = '/__data.json';
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
let pathname =
|
|
18
|
+
export default {
|
|
19
|
+
/**
|
|
20
|
+
* @param {Request} request
|
|
21
|
+
* @returns {Promise<Response>}
|
|
22
|
+
*/
|
|
23
|
+
fetch(request) {
|
|
24
|
+
// If this is an ISR request, the requested pathname is encoded
|
|
25
|
+
// as a search parameter, so we need to extract it
|
|
26
|
+
const url = new URL(request.url);
|
|
27
|
+
let pathname = url.searchParams.get('__pathname');
|
|
28
28
|
|
|
29
29
|
if (pathname) {
|
|
30
|
-
params.delete('__pathname');
|
|
31
30
|
// Optional routes' pathname replacements look like `/foo/$1/bar` which means we could end up with an url like /foo//bar
|
|
32
31
|
pathname = pathname.replace(/\/+/g, '/');
|
|
33
|
-
req.url = `${pathname}${path.endsWith(DATA_SUFFIX) ? DATA_SUFFIX : ''}?${params}`;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
32
|
|
|
37
|
-
|
|
33
|
+
url.pathname = pathname + (url.pathname.endsWith(DATA_SUFFIX) ? DATA_SUFFIX : '');
|
|
34
|
+
url.searchParams.delete('__pathname');
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
request = new Request(url, request);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return server.respond(request, {
|
|
42
40
|
getClientAddress() {
|
|
43
41
|
return /** @type {string} */ (request.headers.get('x-forwarded-for'));
|
|
44
42
|
}
|
|
45
|
-
})
|
|
46
|
-
|
|
43
|
+
});
|
|
44
|
+
}
|
|
47
45
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/adapter-vercel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.0",
|
|
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.
|
|
45
|
+
"@sveltejs/kit": "^2.32.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@sveltejs/kit": "^2.4.0"
|