mirror of
https://github.com/versia-pub/server.git
synced 2026-01-26 20:26:01 +01:00
fix: 🐛 Make sure reverse proxies don't tamper with URLs
This commit is contained in:
parent
9f262c12d6
commit
e9e33432c2
|
|
@ -71,6 +71,16 @@ export default (app: Hono) =>
|
||||||
const currentUrl = new URL(context.req.url);
|
const currentUrl = new URL(context.req.url);
|
||||||
const redirectUrl = new URL(context.req.url);
|
const redirectUrl = new URL(context.req.url);
|
||||||
|
|
||||||
|
// Correct some reverse proxies incorrectly setting the protocol as http, even if the original request was https
|
||||||
|
// Looking at you, Traefik
|
||||||
|
if (
|
||||||
|
new URL(config.http.base_url).protocol === "https:" &&
|
||||||
|
currentUrl.protocol === "http:"
|
||||||
|
) {
|
||||||
|
currentUrl.protocol = "https:";
|
||||||
|
redirectUrl.protocol = "https:";
|
||||||
|
}
|
||||||
|
|
||||||
// Remove state query parameter from URL
|
// Remove state query parameter from URL
|
||||||
currentUrl.searchParams.delete("state");
|
currentUrl.searchParams.delete("state");
|
||||||
redirectUrl.searchParams.delete("state");
|
redirectUrl.searchParams.delete("state");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue