forked from fahrPool/fahrPool
Adds web/Dockerfile (multi-stage node:22-alpine build, standalone output) and web/.dockerignore, and wires a `web` service into docker-compose.yaml so the whole stack (self-hosted Supabase + Next.js) starts with a single `docker compose up -d`. Networking fix: Next.js inlines NEXT_PUBLIC_* env vars at build time into every compiled bundle, including server-side ones (Server Actions, Server Components, Middleware) - not just the browser bundle. Since NEXT_PUBLIC_SUPABASE_URL must point at the externally-reachable http://localhost:8000 for the browser, the server-side Supabase clients in lib/supabase/server.ts and lib/supabase/middleware.ts got that same literal baked in - which resolves to the web container itself (not kong) once running in Docker, causing ECONNREFUSED on any server-side Supabase call (most visibly signInWithPassword in the login server action). Fix: introduce SUPABASE_INTERNAL_URL, a server-only env var without the NEXT_PUBLIC_ prefix, so it's read at actual runtime rather than inlined at build time. It points at http://kong:8000 in docker-compose.yaml (same pattern already used by the studio service's internal SUPABASE_URL) and at http://localhost:8000 in web/.env.local(.example) for non-Docker local dev, where there's no container networking boundary. lib/supabase/client.ts (browser-only) is untouched and keeps reading NEXT_PUBLIC_SUPABASE_URL. Considered extra_hosts: ["localhost:host-gateway"] instead, but rejected it: overriding what the literal string "localhost" resolves to inside a container is unreliable (glibc's resolver typically still prioritizes the container's own loopback), and is the kind of workaround that looks fixed in a quick check and quietly breaks later. Verified end-to-end against the running container via curl (unauth redirect, real signInWithPassword through the login server action, authenticated dashboard content, logout) with zero ECONNREFUSED in `docker compose logs web` afterward, plus a local `npm run dev` smoke test to confirm non-Docker development still works unchanged. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| app | ||
| components | ||
| lib | ||
| public | ||
| .dockerignore | ||
| .env.local.example | ||
| .gitignore | ||
| Dockerfile | ||
| README.md | ||
| eslint.config.mjs | ||
| middleware.ts | ||
| next.config.ts | ||
| package-lock.json | ||
| package.json | ||
| tsconfig.json | ||
| vitest.config.ts | ||
README.md
This is a Next.js project bootstrapped with create-next-app.
Getting Started
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
Learn More
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
Deploy on Vercel
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.