Next.js Discord

Discord Forum

Runtime configuration for SSR variables

Unanswered
American black bear posted this in #help-forum
Open in Discord
American black bearOP
Is it possible to configure server side variables that are picked up after the project is built? For example, I want to pass a connection string to an API that I'm rewriting to a /api path. Do I have to have it in my .env.local or .env.production at build time? Can I configure it at runtime to pick up an environment variable on the server to use for the connection string?

1 Reply

Asian black bear
If you host it on Vercel, they make you rebuild the project to change environment variables. This is because they might affect the build process as well as runtime.