Skip to content

Commit 384f1af

Browse files
Add --host option npx gulp server
Using `0.0.0.0` instead of `localhost` allows connecting from other devices, significantly simplifying testing on mobile devices. This is controlled by the `--host` CLI flag and not enabled by default, since allowing external connections comes with security implications (e.g. when on a public network without a properly configured firewall). There might be reasons to want to listen on custom hostnames, but as the most common usage will probably be `--host 0.0.0.0`, there is a shorter alias `--host 0` for it.
1 parent 3eca607 commit 384f1af

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

gulpfile.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2210,8 +2210,17 @@ gulp.task(
22102210
}
22112211
}
22122212

2213+
let host;
2214+
const j = process.argv.indexOf("--host");
2215+
if (j >= 0 && j + 1 < process.argv.length) {
2216+
host = process.argv[j + 1];
2217+
if (host === "0") {
2218+
host = "0.0.0.0";
2219+
}
2220+
}
2221+
22132222
const { WebServer } = await import("./test/webserver.mjs");
2214-
const server = new WebServer({ port });
2223+
const server = new WebServer({ host, port });
22152224
server.start();
22162225
}
22172226
)

0 commit comments

Comments
 (0)