diff --git a/README.md b/README.md index e667982..e999f16 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ use on their own machine. | `IE_LIBRARY` | `library` | Starter documents, each imported once. | | `IE_USER` | your login name | The name on commits the server makes for you (the page lets you change yours with `/user`). | | `IE_WIKI` | `live` | `mock`: built-in test articles, no network (the browser tests); `off`: every `/api/wiki/*` route answers 503. | +| `IE_HOSTS` | (none) | Extra host names the dev server answers to, comma-separated. `localhost` and `*.ts.net` (Tailscale) are always allowed. | | `IE_WIKI_LANG` | `en` | Which Wikipedia. | | `IE_WIKI_CONTACT` | unset | An email address, an `https://` URL or `User:Name` for the User-Agent of Wikipedia requests. Without it requests are spaced 6.5 s apart (the page says so once, the first time it is slow); with it, 1 s. Nothing else about you is sent. | | `IE_WEB` | `on` when a model is configured | `off` takes web search and fetch away from the editor agent, whatever the page asks. | diff --git a/server/index.ts b/server/index.ts index e327f3d..a8379f2 100644 --- a/server/index.ts +++ b/server/index.ts @@ -38,6 +38,9 @@ import { linkRoutes } from "./links/routes"; import { Linker } from "./links/scan"; const PORT = Number(process.env.PORT ?? 4747); +// Host names the dev server answers to besides localhost. Tailscale names are allowed so that +// `tailscale serve` works; IE_HOSTS adds more (comma-separated; a leading dot matches subdomains). +const ALLOWED_HOSTS = [".ts.net", ...(process.env.IE_HOSTS ?? "").split(",").map((h) => h.trim()).filter(Boolean)]; const DATA = dataDir(); const PROD = process.env.IE_PROD === "1"; const MODEL = process.env.IE_MODEL ?? "claude-opus-5-5"; @@ -446,7 +449,7 @@ function serveStatic(res: ServerResponse, path: string) { const vite = PROD ? null - : await (await import("vite")).createServer({ root, server: { middlewareMode: true, hmr: { port: PORT + 1 } }, appType: "spa" }); + : await (await import("vite")).createServer({ root, server: { middlewareMode: true, hmr: { port: PORT + 1 }, allowedHosts: ALLOWED_HOSTS }, appType: "spa" }); createServer(async (req, res) => { const url = new URL(req.url ?? "/", "http://x");