@hasna/logs 0.3.31 → 0.3.32
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/server/index.js +9 -6
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -2148,12 +2148,12 @@ function isLocalOpenModeEnabled() {
|
|
|
2148
2148
|
}
|
|
2149
2149
|
function isTrustedLocalRequest(c) {
|
|
2150
2150
|
const url = new URL(c.req.url);
|
|
2151
|
-
const
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
return
|
|
2151
|
+
const hosts = [
|
|
2152
|
+
hostWithoutPort(c.req.header("host")),
|
|
2153
|
+
url.hostname,
|
|
2154
|
+
...forwardedHosts(c.req.header("x-forwarded-host"))
|
|
2155
|
+
].filter((host) => Boolean(host));
|
|
2156
|
+
return hosts.length > 0 && hosts.every((host) => isLocalHost(host)) && isLocalOrigin(c.req.header("origin"));
|
|
2157
2157
|
}
|
|
2158
2158
|
function hostWithoutPort(value) {
|
|
2159
2159
|
if (!value)
|
|
@@ -2162,6 +2162,9 @@ function hostWithoutPort(value) {
|
|
|
2162
2162
|
return value.slice(1, value.indexOf("]"));
|
|
2163
2163
|
return value.split(":")[0] || null;
|
|
2164
2164
|
}
|
|
2165
|
+
function forwardedHosts(value) {
|
|
2166
|
+
return value?.split(",").map((host) => hostWithoutPort(host.trim())).filter((host) => Boolean(host)) ?? [];
|
|
2167
|
+
}
|
|
2165
2168
|
function isLocalOrigin(origin) {
|
|
2166
2169
|
if (!origin)
|
|
2167
2170
|
return true;
|