未验证 提交 71850e31 编写于 作者: A Asher

Avoid setting ?to=/

That's the default so it's extra visual noise.
上级 b8340a2a
......@@ -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,
})
}
......
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,
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册