Avoid setting ?to=/
That's the default so it's extra visual noise.
This commit is contained in:
parent
b8340a2ae9
commit
71850e312b
|
@ -55,7 +55,7 @@ router.all("*", (req, res, next) => {
|
|||
}
|
||||
// Redirect all other pages to the login.
|
||||
return redirect(req, res, "login", {
|
||||
to: req.path,
|
||||
to: req.path !== "/" ? req.path : undefined,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Request, Router } from "express"
|
||||
import qs from "qs"
|
||||
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"
|
||||
|
@ -17,11 +18,11 @@ const getProxyTarget = (req: Request, rewrite: boolean): string => {
|
|||
|
||||
router.all("/(:port)(/*)?", (req, res) => {
|
||||
if (!authenticated(req)) {
|
||||
// If visiting the root (/proxy/:port and nothing else) redirect to the
|
||||
// login page.
|
||||
// If visiting the root (/:port only) redirect to the login page.
|
||||
if (!req.params[0] || req.params[0] === "/") {
|
||||
const to = normalize(`${req.baseUrl}${req.path}`)
|
||||
return redirect(req, res, "login", {
|
||||
to: `${req.baseUrl}${req.path}` || "/",
|
||||
to: to !== "/" ? to : undefined,
|
||||
})
|
||||
}
|
||||
throw new HttpError("Unauthorized", HttpCode.Unauthorized)
|
||||
|
|
|
@ -15,7 +15,8 @@ const vscode = new VscodeProvider()
|
|||
router.get("/", async (req, res) => {
|
||||
if (!authenticated(req)) {
|
||||
return redirect(req, res, "login", {
|
||||
to: req.baseUrl,
|
||||
// req.baseUrl can be blank if already at the root.
|
||||
to: req.baseUrl && req.baseUrl !== "/" ? req.baseUrl : undefined,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue