Skip to content

Commit 499cc00

Browse files
author
John McCambridge
committed
Refactor to only use 127.0.0.1 if noauth or allow-http flags are used
1 parent 9a2be81 commit 499cc00

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/server/src/cli.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ commander.version(process.env.VERSION || "development")
2424
.option("-e, --extensions-dir <dir>", "Set the root path for extensions.")
2525
.option("-d --user-data-dir <dir>", " Specifies the directory that user data is kept in, useful when running as root.")
2626
.option("--data-dir <value>", "DEPRECATED: Use '--user-data-dir' instead. Customize where user-data is stored.")
27-
.option("-h, --host <value>", "Customize the hostname.", "127.0.0.1")
27+
.option("-h, --host <value>", "Customize the hostname.", "0.0.0.0")
2828
.option("-o, --open", "Open in the browser on startup.", false)
2929
.option("-p, --port <number>", "Port to bind on.", 8443)
3030
.option("-N, --no-auth", "Start without requiring authentication.", undefined)
@@ -50,7 +50,7 @@ const bold = (text: string | number): string | number => {
5050
const options = commander.opts() as {
5151
noAuth: boolean;
5252
readonly allowHttp: boolean;
53-
readonly host: string;
53+
host: string;
5454
readonly port: number;
5555

5656
readonly userDataDir?: string;
@@ -235,8 +235,13 @@ const bold = (text: string | number): string | number => {
235235
} : undefined,
236236
});
237237

238-
logger.info("Starting webserver...", field("host", options.host), field("port", options.port));
239-
app.server.listen(options.port, options.host);
238+
if (options.noAuth || options.allowHttp) {
239+
logger.info("Starting webserver...", field("host", "127.0.0.1"), field("port", options.port));
240+
app.server.listen(options.port, "127.0.0.1");
241+
} else {
242+
logger.info("Starting webserver...", field("host", options.host), field("port", options.port));
243+
app.server.listen(options.port, options.host);
244+
}
240245
let clientId = 1;
241246
app.wss.on("connection", (ws, req) => {
242247
const id = clientId++;

0 commit comments

Comments
 (0)