Skip to content

Commit cfbf623

Browse files
committed
fix: let self-hosted web builds bake their own public URL
The web Dockerfile hardcodes NEXT_PUBLIC_WEB_URL=http://localhost:3000. Next inlines NEXT_PUBLIC_* into the client bundle, so that value reaches the browser no matter what WEB_URL or CAP_URL says at runtime: share links, embeds, oEmbed and the CORS allowlist all use localhost on a self-hosted build. Back the ENV with an ARG of the same default so a build can pass --build-arg NEXT_PUBLIC_WEB_URL=... without changing the published image.
1 parent 284ae24 commit cfbf623

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

apps/web/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ COPY . .
1212
RUN --mount=type=cache,id=bun-1.4.0,target=/root/.bun/install/cache bun install --frozen-lockfile
1313

1414
ARG NEXT_PUBLIC_DOCKER_BUILD=true
15-
ENV NEXT_PUBLIC_WEB_URL=http://localhost:3000
15+
ARG NEXT_PUBLIC_WEB_URL=http://localhost:3000
16+
ENV NEXT_PUBLIC_WEB_URL=$NEXT_PUBLIC_WEB_URL
1617

1718
RUN bun run build:web
1819

apps/web/content/docs/self-hosting.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ MYSQL_PASSWORD=your-secure-password
7070
MINIO_ROOT_PASSWORD=your-minio-password
7171
```
7272

73+
**Building your own web image:**
74+
75+
`CAP_URL` is read at runtime by the server, but the browser bundle gets its copy of the public URL baked in at build time from `NEXT_PUBLIC_WEB_URL`. The pre-built `ghcr.io` image bakes `http://localhost:3000`. If you build `apps/web/Dockerfile` yourself, pass your public URL as a build argument so share links, embeds and CORS work in the browser:
76+
77+
```bash
78+
docker build -f apps/web/Dockerfile --build-arg NEXT_PUBLIC_WEB_URL=https://cap.yourdomain.com .
79+
```
80+
7381
### Option 2: Railway (One-Click)
7482

7583
[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/new/template/PwpGcf)

0 commit comments

Comments
 (0)