Archived
1
0

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

View File

@ -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,
})
}