diff --git a/Dockerfile b/Dockerfile index 97abf09..da30611 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,6 +60,6 @@ ENV CONNECTOR_BIN=/app/connector-bin/ts-connector EXPOSE 8080 HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ - CMD ["node", "-e", "fetch('http://127.0.0.1:8080/').then(r => { if (!r.ok) process.exit(1) }).catch(() => process.exit(1))"] + CMD ["node", "-e", "fetch('http://127.0.0.1:8080/healthz').then(r => { if (!r.ok) process.exit(1) }).catch(() => process.exit(1))"] CMD ["node", "dist/index.js"] diff --git a/gateway/src/index.ts b/gateway/src/index.ts index cc70bb2..e685c94 100644 --- a/gateway/src/index.ts +++ b/gateway/src/index.ts @@ -251,19 +251,6 @@ const DEV_HINT = `
-WebSocket endpoint: /ws
No web UI is served from this host.
-`; - /** * TLS material, when configured. * @@ -292,17 +279,24 @@ const requestHandler = (req: IncomingMessage, res: ServerResponse) => { return; } + // Container healthcheck target (see Dockerfile). Deliberately its own + // route rather than "/": with WEB_STATIC=0 every browser-facing path + // answers 404, and a probe against "/" would then report the process as + // unhealthy for doing exactly what it was configured to do. + if (requestUrl.pathname === "/healthz") { + res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" }); + res.end("ok\n"); + return; + } + if (!SERVE_STATIC) { - // No SPA fallback here: with the UI hosted elsewhere, answering every - // path with a page would put a second, stale-looking "app" on this - // hostname. Only "/" gets a notice, everything else is simply absent. - if (requestUrl.pathname !== "/") { - res.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" }); - res.end("Not found\n"); - return; - } - res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }); - res.end(NO_UI_NOTICE); + // With the UI hosted elsewhere this process is an API endpoint and + // nothing else: no SPA fallback, and not even a notice page at "/", + // which would only put a second, stale-looking "app" on a hostname + // that is meant to answer /ws and /api/feedback. Everything a browser + // asks for is simply absent. + res.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" }); + res.end("Not found\n"); return; } let filePath = path.join(WEB_DIST, decodeURIComponent(requestUrl.pathname));