@hono/auth-js 1.0.9 → 1.0.10
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/index.js +9 -8
- package/dist/index.mjs +9 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37,11 +37,11 @@ function setEnvDefaults(env2, config) {
|
|
|
37
37
|
config.basePath ||= "/api/auth";
|
|
38
38
|
(0, import_core2.setEnvDefaults)(env2, config);
|
|
39
39
|
}
|
|
40
|
-
async function cloneRequest(input, request) {
|
|
40
|
+
async function cloneRequest(input, request, headers) {
|
|
41
41
|
if ((0, import_adapter.getRuntimeKey)() === "bun") {
|
|
42
42
|
return new Request(input, {
|
|
43
43
|
method: request.method,
|
|
44
|
-
headers: new Headers(request.headers),
|
|
44
|
+
headers: headers ?? new Headers(request.headers),
|
|
45
45
|
body: request.method === "GET" || request.method === "HEAD" ? void 0 : await request.blob(),
|
|
46
46
|
// @ts-ignore: TS2353
|
|
47
47
|
referrer: "referrer" in request ? request.referrer : void 0,
|
|
@@ -68,8 +68,9 @@ async function reqWithEnvUrl(req, authUrl) {
|
|
|
68
68
|
return cloneRequest(reqUrlObj.href, req);
|
|
69
69
|
} else {
|
|
70
70
|
const url = new URL(req.url);
|
|
71
|
-
const
|
|
72
|
-
const
|
|
71
|
+
const headers = new Headers(req.headers);
|
|
72
|
+
const proto = headers.get("x-forwarded-proto");
|
|
73
|
+
const host = headers.get("x-forwarded-host") ?? headers.get("host");
|
|
73
74
|
if (proto != null)
|
|
74
75
|
url.protocol = proto.endsWith(":") ? proto : proto + ":";
|
|
75
76
|
if (host != null) {
|
|
@@ -79,11 +80,11 @@ async function reqWithEnvUrl(req, authUrl) {
|
|
|
79
80
|
url.port = portMatch[1];
|
|
80
81
|
else
|
|
81
82
|
url.port = "";
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
headers.delete("x-forwarded-host");
|
|
84
|
+
headers.delete("Host");
|
|
85
|
+
headers.set("Host", host);
|
|
85
86
|
}
|
|
86
|
-
return cloneRequest(url.href, req);
|
|
87
|
+
return cloneRequest(url.href, req, headers);
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
async function getAuthUser(c) {
|
package/dist/index.mjs
CHANGED
|
@@ -8,11 +8,11 @@ function setEnvDefaults(env2, config) {
|
|
|
8
8
|
config.basePath ||= "/api/auth";
|
|
9
9
|
coreSetEnvDefaults(env2, config);
|
|
10
10
|
}
|
|
11
|
-
async function cloneRequest(input, request) {
|
|
11
|
+
async function cloneRequest(input, request, headers) {
|
|
12
12
|
if (getRuntimeKey() === "bun") {
|
|
13
13
|
return new Request(input, {
|
|
14
14
|
method: request.method,
|
|
15
|
-
headers: new Headers(request.headers),
|
|
15
|
+
headers: headers ?? new Headers(request.headers),
|
|
16
16
|
body: request.method === "GET" || request.method === "HEAD" ? void 0 : await request.blob(),
|
|
17
17
|
// @ts-ignore: TS2353
|
|
18
18
|
referrer: "referrer" in request ? request.referrer : void 0,
|
|
@@ -39,8 +39,9 @@ async function reqWithEnvUrl(req, authUrl) {
|
|
|
39
39
|
return cloneRequest(reqUrlObj.href, req);
|
|
40
40
|
} else {
|
|
41
41
|
const url = new URL(req.url);
|
|
42
|
-
const
|
|
43
|
-
const
|
|
42
|
+
const headers = new Headers(req.headers);
|
|
43
|
+
const proto = headers.get("x-forwarded-proto");
|
|
44
|
+
const host = headers.get("x-forwarded-host") ?? headers.get("host");
|
|
44
45
|
if (proto != null)
|
|
45
46
|
url.protocol = proto.endsWith(":") ? proto : proto + ":";
|
|
46
47
|
if (host != null) {
|
|
@@ -50,11 +51,11 @@ async function reqWithEnvUrl(req, authUrl) {
|
|
|
50
51
|
url.port = portMatch[1];
|
|
51
52
|
else
|
|
52
53
|
url.port = "";
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
headers.delete("x-forwarded-host");
|
|
55
|
+
headers.delete("Host");
|
|
56
|
+
headers.set("Host", host);
|
|
56
57
|
}
|
|
57
|
-
return cloneRequest(url.href, req);
|
|
58
|
+
return cloneRequest(url.href, req, headers);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
async function getAuthUser(c) {
|