fix: listen on all interfaces for LAN testing

This commit is contained in:
2026-09-22 16:39:45 +08:00
parent cacbabea85
commit bd7585776d
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -9,6 +9,6 @@ npm ci
npm run dev
```
Then open <http://127.0.0.1:4173/> in Chromium.
The server listens on `0.0.0.0:4173` by default. Open `http://127.0.0.1:4173/` locally, or `http://<主机局域网IP>:4173/` from another device.
The public checkout intentionally excludes private research inputs and local acceptance artifacts; those are kept in the developer workspace and are covered by `.gitignore`.
+4 -3
View File
@@ -1,9 +1,10 @@
import { createReadStream } from "node:fs";
import { stat } from "node:fs/promises";
import { createServer } from "node:http";
import { extname, join, normalize, relative, resolve } from "node:path";
import { extname, join, relative, resolve } from "node:path";
const root = resolve("dist");
const host = process.env.HOST ?? "0.0.0.0";
const port = Number(process.env.PORT ?? 4173);
const contentTypes = {
".html": "text/html; charset=utf-8",
@@ -31,6 +32,6 @@ const server = createServer(async (request, response) => {
}
});
server.listen(port, "127.0.0.1", () => {
console.log(`JPW7 M0 server listening on http://127.0.0.1:${port}`);
server.listen(port, host, () => {
console.log(`JPW7 M0 server listening on http://${host}:${port}`);
});