@openworkers/adapter-sveltekit 0.4.3 → 0.4.5
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/dist/function-worker.js +10 -0
- package/dist/worker.js +4 -0
- package/package.json +1 -1
package/dist/function-worker.js
CHANGED
|
@@ -3,6 +3,10 @@ import * as handlers from "ENDPOINT";
|
|
|
3
3
|
var worker = {
|
|
4
4
|
async fetch(req, env, ctx) {
|
|
5
5
|
globalThis.env = env;
|
|
6
|
+
const proto = req.headers.get("x-forwarded-proto");
|
|
7
|
+
if (proto && !req.url.startsWith(proto)) {
|
|
8
|
+
req = new Request(req.url.replace(/^http:/, `${proto}:`), req);
|
|
9
|
+
}
|
|
6
10
|
const method = req.method;
|
|
7
11
|
const handler = handlers[method];
|
|
8
12
|
if (!handler) {
|
|
@@ -52,6 +56,12 @@ var worker = {
|
|
|
52
56
|
}
|
|
53
57
|
return response;
|
|
54
58
|
} catch (error) {
|
|
59
|
+
if (error?.status >= 300 && error?.status < 400 && error?.location) {
|
|
60
|
+
return new Response(null, {
|
|
61
|
+
status: error.status,
|
|
62
|
+
headers: { Location: error.location }
|
|
63
|
+
});
|
|
64
|
+
}
|
|
55
65
|
if (error?.status && error?.body) {
|
|
56
66
|
return new Response(JSON.stringify(error.body), {
|
|
57
67
|
status: error.status,
|
package/dist/worker.js
CHANGED
|
@@ -31,6 +31,10 @@ var initialized = server.init({
|
|
|
31
31
|
var worker = {
|
|
32
32
|
async fetch(req, env, ctx) {
|
|
33
33
|
globalThis.env = env;
|
|
34
|
+
const proto = req.headers.get("x-forwarded-proto");
|
|
35
|
+
if (proto && !req.url.startsWith(proto)) {
|
|
36
|
+
req = new Request(req.url.replace(/^http:/, `${proto}:`), req);
|
|
37
|
+
}
|
|
34
38
|
if (!origin) {
|
|
35
39
|
origin = new URL(req.url).origin;
|
|
36
40
|
}
|