@vesk/adapter 0.2.90 → 0.2.92
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-handler.d.ts","sourceRoot":"","sources":["../src/platform-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AASvE,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAMpD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC;AAgBD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"platform-handler.d.ts","sourceRoot":"","sources":["../src/platform-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AASvE,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAMpD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC;AAgBD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CA4PjF;AAED,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4GzF;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
package/dist/platform-handler.js
CHANGED
|
@@ -156,6 +156,19 @@ export async function handleRequest(request) {
|
|
|
156
156
|
const pathname = url.pathname;
|
|
157
157
|
const isDataRequest = request.headers.get('x-vesk-data') === '1';
|
|
158
158
|
${serverStoreLine}
|
|
159
|
+
// During SSR, fetch() with a relative URL (e.g. '/api/student') throws
|
|
160
|
+
// because undici requires an absolute URL and there is no browser
|
|
161
|
+
// origin to resolve against. Wrap globalThis.fetch for the duration
|
|
162
|
+
// of the handler so relative API calls resolve against the request's
|
|
163
|
+
// origin — matching what the client does automatically.
|
|
164
|
+
const origin = url.origin;
|
|
165
|
+
const origFetch = globalThis.fetch;
|
|
166
|
+
globalThis.fetch = async (input, init) => {
|
|
167
|
+
if (typeof input === 'string' && input.startsWith('/')) {
|
|
168
|
+
input = origin + input;
|
|
169
|
+
}
|
|
170
|
+
return origFetch(input, init);
|
|
171
|
+
};
|
|
159
172
|
|
|
160
173
|
if (__prerendered.has(pathname) && !isDataRequest) {
|
|
161
174
|
return new Response(null, { status: 308, headers: { Location: '/_vesk/static/public' + (pathname.endsWith('/') ? pathname + 'index.html' : pathname + '.html') } });
|
|
@@ -250,6 +263,7 @@ ${eventsRequestLine}
|
|
|
250
263
|
headers: { 'Content-Type': 'text/html' },
|
|
251
264
|
});
|
|
252
265
|
} catch (e) {
|
|
266
|
+
globalThis.fetch = origFetch;
|
|
253
267
|
// Any error that escapes the route (a thrown exception, a bad import, a
|
|
254
268
|
// middleware failure, ...) must not bubble out of handleRequest. On
|
|
255
269
|
// serverless platforms (Vercel, Netlify, Cloudflare) an uncaught throw is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prod-server.d.ts","sourceRoot":"","sources":["../src/prod-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,eAAe,EAAuB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAejG,OAAO,KAAK,EAAkB,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAIpG,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC;AAuIrD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,GAAG,CAY9F;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"prod-server.d.ts","sourceRoot":"","sources":["../src/prod-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,eAAe,EAAuB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAejG,OAAO,KAAK,EAAkB,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAIpG,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC;AAuIrD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,GAAG,CAY9F;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmpBlG"}
|
package/dist/prod-server.js
CHANGED
|
@@ -636,8 +636,21 @@ export async function startProdServer(outDir, options) {
|
|
|
636
636
|
if (params) {
|
|
637
637
|
const mod = await loadFunction(route.function);
|
|
638
638
|
if (mod) {
|
|
639
|
+
const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
|
|
640
|
+
// During SSR, fetch() with a relative URL (e.g. '/api/student') throws
|
|
641
|
+
// because undici requires an absolute URL and there is no browser
|
|
642
|
+
// origin to resolve against. Wrap globalThis.fetch for the duration
|
|
643
|
+
// of the SSR render so relative API calls resolve against the
|
|
644
|
+
// request's origin — matching what the client does automatically.
|
|
645
|
+
const origin = new URL(url.href).origin;
|
|
646
|
+
const origFetch = globalThis.fetch;
|
|
647
|
+
globalThis.fetch = async (input, init) => {
|
|
648
|
+
if (typeof input === 'string' && input.startsWith('/')) {
|
|
649
|
+
input = origin + input;
|
|
650
|
+
}
|
|
651
|
+
return origFetch(input, init);
|
|
652
|
+
};
|
|
639
653
|
try {
|
|
640
|
-
const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
|
|
641
654
|
let cachedResult = null;
|
|
642
655
|
if (route.revalidate && route.revalidate > 0) {
|
|
643
656
|
const { pageIsr } = await import('@vesk/runtime/src/index-server');
|
|
@@ -719,6 +732,9 @@ export async function startProdServer(outDir, options) {
|
|
|
719
732
|
res.end(errorHtml || renderDefaultErrorPage({ message: process.env.NODE_ENV !== 'production' ? err.message : undefined, url: url.pathname, headExtra: bakedHeadExtra }));
|
|
720
733
|
return;
|
|
721
734
|
}
|
|
735
|
+
finally {
|
|
736
|
+
globalThis.fetch = origFetch;
|
|
737
|
+
}
|
|
722
738
|
}
|
|
723
739
|
}
|
|
724
740
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/adapter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.92",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk adapter — builds deployable .vesk/ output for Deno and Node serverless",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"sharp": "^0.35.3"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@vesk/compiler": "^0.2.
|
|
27
|
-
"@vesk/runtime": "^0.2.
|
|
28
|
-
"@vesk/types": "^0.2.
|
|
26
|
+
"@vesk/compiler": "^0.2.92",
|
|
27
|
+
"@vesk/runtime": "^0.2.92",
|
|
28
|
+
"@vesk/types": "^0.2.92"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/ws": "^8.18.1",
|