CLOUDFLARE_TOKEN is set, the egg downloads the cloudflared binary at startup, then runs the tunnel in the background alongside your Next.js app.
Prerequisites
- A Cloudflare account with Zero Trust enabled
- A tunnel created and configured in the Cloudflare dashboard
Steps
Open the Zero Trust dashboard
Go to the Cloudflare Zero Trust dashboard and navigate to Networks → Tunnels.
Create or select a tunnel
Click Create a tunnel (or open an existing one). Choose Cloudflared as the connector type and follow the prompts to name your tunnel.
Copy the run token
After creating the tunnel, Cloudflare displays a Run token in the tunnel’s configuration page. Copy this value.
Set the token in the panel
In your server’s startup variables, set
CLOUDFLARE_TOKEN to the token you copied.Configure the public hostname
In the tunnel configuration, add a Public Hostname that points to
Replace
localhost on your server’s SERVER_PORT. For example:| Field | Value |
|---|---|
| Hostname | app.yourdomain.com |
| Service | http://localhost:25565 |
25565 with the port assigned to your server.The tunnel runs in the background as a separate process. Your Next.js app still binds to
SERVER_PORT internally — the tunnel forwards external traffic to that port.