Skip to content

Commit c5ed2f8

Browse files
nhooyrJoe Previte
authored and
Joe Previte
committed
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.
1 parent 7379828 commit c5ed2f8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/node/routes/index.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { plural } from "../../common/util"
1111
import { AuthType, DefaultedArgs } from "../cli"
1212
import { rootPath } from "../constants"
1313
import { Heart } from "../heart"
14-
import { replaceTemplates } from "../http"
14+
import { replaceTemplates, redirect } from "../http"
1515
import { PluginAPI } from "../plugin"
1616
import { getMediaMime, paths } from "../util"
1717
import { WebsocketRequest } from "../wsRouter"
@@ -112,6 +112,10 @@ export const register = async (
112112

113113
if (args.auth === AuthType.Password) {
114114
app.use("/login", login.router)
115+
} else {
116+
app.all("/login", (req, res) => {
117+
redirect(req, res, "/", {})
118+
})
115119
}
116120

117121
app.use("/proxy", proxy.router)

0 commit comments

Comments
 (0)