From 5499a3d12562f4b5b15cb684f53428a8f68798e6 Mon Sep 17 00:00:00 2001 From: Asher Date: Thu, 12 Nov 2020 11:23:52 -0600 Subject: [PATCH] Use baseUrl when redirecting from domain proxy This will make the route more robust since it'll work under more than just the root. --- src/node/routes/domainProxy.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node/routes/domainProxy.ts b/src/node/routes/domainProxy.ts index fdffdc58..25745955 100644 --- a/src/node/routes/domainProxy.ts +++ b/src/node/routes/domainProxy.ts @@ -1,5 +1,6 @@ import { Request, Router } from "express" import { HttpCode, HttpError } from "../../common/http" +import { normalize } from "../../common/util" import { authenticated, ensureAuthenticated, redirect } from "../http" import { proxy } from "../proxy" import { Router as WsRouter } from "../wsRouter" @@ -54,8 +55,9 @@ router.all("*", (req, res, next) => { return next() } // Redirect all other pages to the login. + const to = normalize(`${req.baseUrl}${req.path}`) return redirect(req, res, "login", { - to: req.path !== "/" ? req.path : undefined, + to: to !== "/" ? to : undefined, }) }