From f348b60c2a77a8aa268cf21413222f9e7b0e1365 Mon Sep 17 00:00:00 2001 From: swithek <52840391+swithek@users.noreply.github.com> Date: Thu, 6 Aug 2026 12:07:32 +0200 Subject: [PATCH] update env vars --- CLAUDE.md | 2 +- Makefile | 3 ++- docker/docker-compose.dev.yaml | 6 ++++++ docker/env/web.example.env | 18 ++++++++++-------- web/.env.example | 22 ---------------------- web/vite.electron.config.ts | 4 ++-- 6 files changed, 21 insertions(+), 34 deletions(-) delete mode 100644 web/.env.example diff --git a/CLAUDE.md b/CLAUDE.md index 604f5571..109ee448 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -75,7 +75,7 @@ Strong success criteria let you loop independently. Weak criteria ("make it work - `server/core/` — Go API server (`oxynote-core`). Go module `github.com/oxynote/oxynote/server/core`. Details: [server/CLAUDE.md](server/CLAUDE.md). - `server/auth-realtime/` — Node service (`@oxynote/auth-realtime`, **pnpm**) running Better Auth and a Hocuspocus (Yjs) server in one Hono process. Details: [server/CLAUDE.md](server/CLAUDE.md). - `datagen/` — demo-data generator; separate Go module `github.com/oxynote/oxynote/datagen`. Demo/testing only. -- `docker/` — dev docker-compose stack, Caddyfile, `env/` (committed `*.example.env` templates; `make setup` copies them to gitignored `*.local.env`, which is what the compose stack reads), `demo/` (demo-data configs for mariadb/postgres/prometheus). +- `docker/` — dev docker-compose stack, Caddyfile, `env/` (committed `*.example.env` templates; `make setup` copies them to the gitignored `*.local.env` files the compose stack reads, and `web.example.env` also to `web/.env` for the host dev server and electron builds), `demo/` (demo-data configs for mariadb/postgres/prometheus). ## Common commands diff --git a/Makefile b/Makefile index 8e0c6e6b..42313102 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ start: build-go # stops the web dev server; `make stop` stops the containers. dev: build-go $(COMPOSE) up --build -d - cd web && pnpm run start:dev:web + cd web && NUXT_PUBLIC_APP_BASE_URL=http://localhost:3000 pnpm run start:dev:web stop: $(COMPOSE) --profile web down @@ -30,6 +30,7 @@ setup: for f in core auth-realtime web; do \ test -f docker/env/$$f.local.env || cp docker/env/$$f.example.env docker/env/$$f.local.env; \ done + test -f web/.env || cp docker/env/web.example.env web/.env deps: cd web && pnpm run deps diff --git a/docker/docker-compose.dev.yaml b/docker/docker-compose.dev.yaml index 599bd419..65de01d6 100644 --- a/docker/docker-compose.dev.yaml +++ b/docker/docker-compose.dev.yaml @@ -20,6 +20,12 @@ services: web: container_name: web image: ghcr.io/oxynote/web:dev + environment: + # SSR inside the container must reach the services directly; these + # compose hostnames don't resolve on the host, which is why they live + # here and not in the shared env template. + - NUXT_CORE_API_INTERNAL_HTTP_URL=http://core:8080 + - NUXT_AUTH_REALTIME_API_INTERNAL_HTTP_URL=http://auth-realtime:8081 # not started by plain `up` — `make dev` runs web on the host instead; # `make run` / `make start` enable this profile for the full stack. profiles: diff --git a/docker/env/web.example.env b/docker/env/web.example.env index dc5147ca..b7ae2c98 100644 --- a/docker/env/web.example.env +++ b/docker/env/web.example.env @@ -1,7 +1,9 @@ -# every runtime-config variable the web app reads is listed here -# explicitly, even when empty. `make setup` copies this template to -# web.local.env (gitignored) when missing; the dev compose reads only the -# .local.env file. The node-server build reads these at container start. +# the single env template for the web app. `make setup` copies it to both +# web.local.env (read by the web container at start) and web/.env (auto- +# loaded by the host `nuxt dev` server and the electron builds). Every +# runtime-config variable the web app reads is listed explicitly, even when +# empty. `make dev` overrides NUXT_PUBLIC_APP_BASE_URL to the dev server's +# :3000 origin. # public URLs (what the browser uses — the caddy front door) NUXT_PUBLIC_APP_BASE_URL=http://localhost:8080 @@ -10,10 +12,6 @@ NUXT_PUBLIC_AUTH_REALTIME_API_BASE_WS_URL=ws://localhost:8080/auth-realtime/hocu NUXT_PUBLIC_CORE_API_BASE_HTTP_URL=http://localhost:8080/core NUXT_PUBLIC_CORE_API_BASE_WS_URL=ws://localhost:8080/core -# server-only URLs (what SSR inside the container uses — service hostnames) -NUXT_CORE_API_INTERNAL_HTTP_URL=http://core:8080 -NUXT_AUTH_REALTIME_API_INTERNAL_HTTP_URL=http://auth-realtime:8081 - # optional NUXT_PUBLIC_SENTRY_DSN= NUXT_PUBLIC_LINK_TO_MORE_INFO_ABOUT_PRODUCT=https://oxynote.io @@ -29,3 +27,7 @@ NUXT_PUBLIC_PROMETHEUS_QUERY_GUIDE_URL=https://prometheus.io/docs/prometheus/lat NUXT_PUBLIC_POSTGRESQL_QUERY_GUIDE_URL=https://www.postgresql.org/docs/current/sql-select.html NUXT_PUBLIC_MYSQL_QUERY_GUIDE_URL=https://dev.mysql.com/doc/refman/8.0/en/select.html NUXT_PUBLIC_MARIADB_QUERY_GUIDE_URL=https://mariadb.com/kb/en/select/ + +# build-time secret for the Sentry build plugin (source map upload); not +# runtime config. +SENTRY_AUTH_TOKEN= diff --git a/web/.env.example b/web/.env.example deleted file mode 100644 index d5ac5ef0..00000000 --- a/web/.env.example +++ /dev/null @@ -1,22 +0,0 @@ -NUXT_PUBLIC_SENTRY_DSN= -NUXT_PUBLIC_APP_BASE_URL=http://localhost:3000 -NUXT_PUBLIC_LINK_TO_MORE_INFO_ABOUT_PRODUCT=https://oxynote.io -NUXT_PUBLIC_AUTH_REALTIME_API_BASE_HTTP_URL=http://localhost:8080/auth-realtime -NUXT_PUBLIC_AUTH_REALTIME_API_BASE_WS_URL=ws://localhost:8080/auth-realtime/hocuspocus -NUXT_PUBLIC_CORE_API_BASE_HTTP_URL=http://localhost:8080/core -NUXT_PUBLIC_CORE_API_BASE_WS_URL=ws://localhost:8080/core -NUXT_PUBLIC_TERMS_OF_SERVICE_URL=https://oxynote.io/terms-of-service -NUXT_PUBLIC_PRIVACY_POLICY_URL=https://oxynote.io/privacy-policy -NUXT_PUBLIC_EXPERIMENTAL_FEATURES= -NUXT_PUBLIC_POSTGRESQL_READ_ONLY_USER_SETUP_GUIDE_URL=https://tableplus.com/blog/2018/04/postgresql-how-to-create-read-only-user.html -NUXT_PUBLIC_MYSQL_READ_ONLY_USER_SETUP_GUIDE_URL=https://guide.trevor.io/hc/en-us/articles/6843804879261-Creating-a-read-only-database-user-in-MySQL -NUXT_PUBLIC_MARIADB_READ_ONLY_USER_SETUP_GUIDE_URL=https://guide.trevor.io/hc/en-us/articles/6843804879261-Creating-a-read-only-database-user-in-MySQL -NUXT_PUBLIC_PROMETHEUS_QUERY_GUIDE_URL=https://prometheus.io/docs/prometheus/latest/querying/basics/ -NUXT_PUBLIC_POSTGRESQL_QUERY_GUIDE_URL=https://www.postgresql.org/docs/current/sql-select.html -NUXT_PUBLIC_MYSQL_QUERY_GUIDE_URL=https://dev.mysql.com/doc/refman/8.0/en/select.html -NUXT_PUBLIC_MARIADB_QUERY_GUIDE_URL=https://mariadb.com/kb/en/select/ - -# DO NOT commit this file to your repository! -# The SENTRY_AUTH_TOKEN variable is picked up by the Sentry Build Plugin. -# It's used for authentication when uploading source maps. -SENTRY_AUTH_TOKEN= \ No newline at end of file diff --git a/web/vite.electron.config.ts b/web/vite.electron.config.ts index 949c267b..01894b3c 100644 --- a/web/vite.electron.config.ts +++ b/web/vite.electron.config.ts @@ -20,12 +20,12 @@ try { // Auth env vars are baked into the bundle at build time. Runtime env can't // override them — this is the security boundary for the desktop app. -const apiBaseURL = process.env.NUXT_PUBLIC_NODEJS_API_BASE_HTTP_URL +const apiBaseURL = process.env.NUXT_PUBLIC_AUTH_REALTIME_API_BASE_HTTP_URL const appBaseURL = process.env.NUXT_PUBLIC_APP_BASE_URL if (!apiBaseURL || !appBaseURL) { throw new Error( - "electron build requires NUXT_PUBLIC_NODEJS_API_BASE_HTTP_URL and NUXT_PUBLIC_APP_BASE_URL env vars", + "electron build requires NUXT_PUBLIC_AUTH_REALTIME_API_BASE_HTTP_URL and NUXT_PUBLIC_APP_BASE_URL env vars", ) }