Open
Description
Link to the code that reproduces this issue
https://github.com/kuanjiahong/env-var-not-defined-docker
To Reproduce
- Start the container with
docker compose up --build
- Go to http://localhost:3000/
- Click the link
Current vs. Expected behavior
Current behaviour:
You are redirected to /fail-to-rewrite
which means process.env.REWRITE_URL
is undefined. This logic comes from the config at next.config.ts
Screenshot showing the rewrite logic in next.config.ts
Expected behaviour:
You should be redirected to https://example.com/ as defined in the docker-compose.yaml
file in the REWRITE_URL
environment variable
Screenshot showing the location where REWRITE_URL
is defined in docker-compose.yaml
Expected page:
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Enterprise
Available memory (MB): 32562
Available CPU cores: 8
Binaries:
Node: 22.12.0
npm: 11.0.0
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 15.3.0-canary.24 // Latest available version is detected (15.3.0-canary.24).
eslint-config-next: N/A
react: 19.0.0
react-dom: 19.0.0
typescript: 5.8.2
Next.js Config:
output: standalone
Which area(s) are affected? (Select all that apply)
Runtime
Which stage(s) are affected? (Select all that apply)
next start (local)
Additional context
I found this issue when I run my project with Docker.
Here are my Docker information:
Client:
Version: 28.0.1
API version: 1.48
Go version: go1.23.6
Git commit: 068a01e
Built: Wed Feb 26 10:41:52 2025
OS/Arch: windows/amd64
Context: desktop-linux
Server: Docker Desktop 4.39.0 (184744)
Engine:
Version: 28.0.1
API version: 1.48 (minimum version 1.24)
Go version: go1.23.6
Git commit: bbd0a17
Built: Wed Feb 26 10:41:16 2025
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.7.25
GitCommit: bcc810d6b9066471b0b6fa75f557a15a1cbf31bb
runc:
Version: 1.2.4
GitCommit: v1.2.4-0-g6c52b3f
docker-init:
Version: 0.19.0
GitCommit: de40ad0
When inspecting the environment variables in the container. The environment variable REWRITE_URL
exist