mirror of
https://github.com/versia-pub/server.git
synced 2025-12-08 01:08:19 +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 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
|
||||
currentUrl.searchParams.delete("state");
|
||||
redirectUrl.searchParams.delete("state");
|
||||
|
|
|
|||
Loading…
Reference in a new issue