learning_ai_notes/web
saravanakumardb1 91b859746b fix(docker): bake NEXT_PUBLIC_* values at build time, drop hardcoded api.bytelyst.com
Root cause: docker-compose.yml hardcoded NEXT_PUBLIC_NOTES_API_URL to
https://api.bytelyst.com/notelett — a production URL that doesn't
exist on this network — as the *build arg* for the web image. The
docker-compose.override.yml correctly set localhost:4016/api but only
on the runtime environment, which has no effect because NEXT_PUBLIC_*
values are baked into the Next.js bundle at build time (pnpm run build
inside the Dockerfile), not read at runtime.

Symptom: every authenticated client-side fetch from the deployed web
container went to https://api.bytelyst.com/notelett/... which the
corporate proxy intercepted with a blockpage. The saved-views client
in particular fired on every (app)/ layout mount, surfacing a
'Failed to fetch' toast on dashboard load. 4 release-flows.spec
tests failed because page.route('**/api/**') couldn't match the
api.bytelyst.com URLs at all.

Discovery: inspected the deployed bundle inside the running container.
'grep -oE "api.bytelyst.com" /app/web/web/.next/static/chunks/*.js'
returned multiple hits across the (app)/ layout, (auth)/ pages, and
share page. The string was absent from the source tree, which proved
it had been injected at build time via the broken arg default.

Discovery debug pattern (kept for future use):
  page.on('requestfailed', r => console.log(r.method(), r.url()));
  page.route('**/api/**', route => route.fulfill({status:200,body:'{}'}));
  await page.goto('/dashboard');
  // FAILED REQUESTS will list any URL not under /api/** that the SPA
  // attempted, exposing baked-in production URLs immediately.

Fix (three layers, defense in depth):

1. docker-compose.yml — replace hardcoded
   'NEXT_PUBLIC_NOTES_API_URL: https://api.bytelyst.com/notelett'
   in the build.args block with
   '${NEXT_PUBLIC_NOTES_API_URL:-http://localhost:4016/api}'.
   Same treatment for the runtime environment block. Add build args
   for the four other NEXT_PUBLIC_* values (extraction, MCP,
   diagnostics, product name/id, telemetry transport) so a single env
   var on the host controls both build and runtime layers.

2. web/Dockerfile — declare ARG and ENV lines for all seven
   NEXT_PUBLIC_* values so the build args reach 'pnpm run build'.
   Previously only NOTES_API_URL and PLATFORM_SERVICE_URL were
   declared, which meant overriding extraction/MCP/diagnostics via
   docker compose silently had no effect on the bundle.

3. docker-compose.override.yml — add a build.args block mirroring the
   four URL overrides so the local-only override also reaches build
   time, not just runtime. Comment block explains the bake-time vs
   runtime distinction so future contributors don't repeat the bug.

Verified end-to-end after the fix:
  - docker compose build --no-cache web + up -d → grep of bundle now
    shows 'localhost:4016/api', api.bytelyst.com fully gone.
  - Debug interception test: zero requestfailed events on /dashboard.
  - Playwright release-flows.spec.ts: 4 failed → 4 passed (after URL
    fix; no test code changed for these four tests).
  - Full Playwright suite (--ignore-snapshots): 43 passed.
  - scripts/e2e-docker-test.sh: 9/9 backend API lifecycle steps pass.
  - pnpm run verify: backend 380/380, web 96/96, mobile 97/97.
2026-05-23 10:04:36 -07:00
..
e2e fix(web): repair Next.js standalone static-chunks 404 in Docker + harden 2 e2e specs 2026-05-23 02:29:40 -07:00
public feat: implement WEB_AI_FAST_ROADMAP (web + backend + docs) 2026-03-31 13:00:36 -07:00
scripts chore(web): add bundle analysis gate 2026-05-05 12:45:20 -07:00
src feat(web/ui8): remove legacy global classes + tighten audit regex + lock CI gate 2026-05-23 01:55:36 -07:00
test-results chore: update dependencies 2026-03-29 10:50:57 -07:00
.env.example fix(platform): align mcp service urls 2026-05-05 09:19:11 -07:00
.gitignore test(e2e): fix 4 pre-existing E2E failures and make port-conflict-proof 2026-05-23 00:50:29 -07:00
Dockerfile fix(docker): bake NEXT_PUBLIC_* values at build time, drop hardcoded api.bytelyst.com 2026-05-23 10:04:36 -07:00
eslint.config.mjs fix(lint): clear production lint blockers 2026-05-05 14:04:49 -07:00
next-env.d.ts feat(web/ui8): remove legacy global classes + tighten audit regex + lock CI gate 2026-05-23 01:55:36 -07:00
next.config.ts fix(web): prepare Vercel build and standalone runtime 2026-03-31 06:05:16 +00:00
package.json test(e2e): fix 4 pre-existing E2E failures and make port-conflict-proof 2026-05-23 00:50:29 -07:00
playwright.config.ts test(e2e): fix 4 pre-existing E2E failures and make port-conflict-proof 2026-05-23 00:50:29 -07:00
tsconfig.json feat(repo): migrate notelett workspace to pnpm 2026-03-22 15:50:54 -07:00
vitest.config.ts fix(web): add Next.js module mocks for Vitest — all 14 tests pass (was 10/14) 2026-03-29 01:03:11 -07:00