Deploying the Next.js frontend initially with NEXT_PUBLIC_API_URL set only as a runtime env var produced a client bundle with an empty API URL. Next.js inlines NEXT_PUBLIC_* variables at build time, so they must be available during the docker build step. Fix: declare ARG NEXT_PUBLIC_API_URL in the Dockerfile and Railway will inject the service env var as a build arg when the ARG name matches.
Applies to any Next.js app containerised and deployed to Railway (or any PaaS with a separate build step). Version: Next.js 13+ with App Router.