From 244afa402e74dec23bacbce0362e25040259dcff Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 14 Dec 2020 12:33:36 -0500 Subject: [PATCH] routes: Redirect from /login when auth is disabled (#2456) Sometimes I start with auth but then disable. Now I can just reload the login page in my browser to be greeted with code-server. --- src/node/routes/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/node/routes/index.ts b/src/node/routes/index.ts index 8a073a319..a7b7c1853 100644 --- a/src/node/routes/index.ts +++ b/src/node/routes/index.ts @@ -11,7 +11,7 @@ import { plural } from "../../common/util" import { AuthType, DefaultedArgs } from "../cli" import { rootPath } from "../constants" import { Heart } from "../heart" -import { replaceTemplates } from "../http" +import { replaceTemplates, redirect } from "../http" import { PluginAPI } from "../plugin" import { getMediaMime, paths } from "../util" import { WebsocketRequest } from "../wsRouter" @@ -112,6 +112,10 @@ export const register = async ( if (args.auth === AuthType.Password) { app.use("/login", login.router) + } else { + app.all("/login", (req, res) => { + redirect(req, res, "/", {}) + }) } app.use("/proxy", proxy.router)