Default server/channel as runtime config for the Docker image (#12)

DEFAULT_SERVER/DEFAULT_CHANNEL used to be build args only, so pointing a
self-hosted instance at its server meant cloning the repo and rebuilding
the image. The gateway now reads them from its own environment and puts
them into the index.html it serves as <meta> tags (HTML-escaped; an
inline script would be blocked by the page's CSP). The client prefers
those over the build-time VITE_ values, which keep working as before.

Closes #12

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
MoepchiandClaude Opus 5.5 committed 2026-10-02 07:26:05 +00:00
1 parent a9f0586b88
commit 8e934c6646
3 files changed
+34 -8

No files matched your search

+8 -4
View File
@@ -162,10 +162,14 @@ const AUTO_CONNECT_FROM_URL = (() => {
// A self-hosted build can also bake in a default server so the page
// auto-connects with zero URL params at all - set via `docker compose build
// --build-arg DEFAULT_SERVER=...` (see Dockerfile/README) or plain
// VITE_DEFAULT_SERVER= at build time. AUTO_CONNECT_FROM_URL above always wins
// when a share link is present.
const DEFAULT_SERVER = import.meta.env.VITE_DEFAULT_SERVER || null;
const DEFAULT_CHANNEL = import.meta.env.VITE_DEFAULT_CHANNEL || "";
// VITE_DEFAULT_SERVER= at build time. The Docker image can set the same thing
// at runtime instead (DEFAULT_SERVER/DEFAULT_CHANNEL env vars, issue #12): the
// gateway passes them in as <meta> tags, which take precedence over the build
// values. AUTO_CONNECT_FROM_URL above always wins when a share link is present.
const runtimeConfig = (name: string) =>
document.querySelector<HTMLMetaElement>(`meta[name="webspeak3-${name}"]`)?.content;
const DEFAULT_SERVER = runtimeConfig("default-server") || import.meta.env.VITE_DEFAULT_SERVER || null;
const DEFAULT_CHANNEL = runtimeConfig("default-channel") || import.meta.env.VITE_DEFAULT_CHANNEL || "";
// Terms of use, own-hosted instance only (see TODO.md #2/#7.1). Versioned so
// a rule change can re-surface the modal: bump TOS_VERSION and everyone who