Use baseUrl when redirecting from domain proxy

This will make the route more robust since it'll work under more than
just the root.
This commit is contained in:
Asher 2020-11-12 11:23:52 -06:00
parent 31b67062b0
commit 5499a3d125
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
1 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import { Request, Router } from "express" import { Request, Router } from "express"
import { HttpCode, HttpError } from "../../common/http" import { HttpCode, HttpError } from "../../common/http"
import { normalize } from "../../common/util"
import { authenticated, ensureAuthenticated, redirect } from "../http" import { authenticated, ensureAuthenticated, redirect } from "../http"
import { proxy } from "../proxy" import { proxy } from "../proxy"
import { Router as WsRouter } from "../wsRouter" import { Router as WsRouter } from "../wsRouter"
@ -54,8 +55,9 @@ router.all("*", (req, res, next) => {
return next() return next()
} }
// Redirect all other pages to the login. // Redirect all other pages to the login.
const to = normalize(`${req.baseUrl}${req.path}`)
return redirect(req, res, "login", { return redirect(req, res, "login", {
to: req.path !== "/" ? req.path : undefined, to: to !== "/" ? to : undefined,
}) })
} }