Menu

It works locally and dies in production: the environment variables AI never writes down
πŸ“°

It works locally and dies in production: the environment variables AI never writes down

DEV Community: nextjsΒ·Youngjun YoonΒ·about 11 hours ago
#bd7zNKrg
#devtonextjs#devto#dev#secret#production
Reading 0:00
15s threshold

Every week somebody sends me an app with the same sentence: "it works on my machine". It usually does. The gap is almost never the code β€” it is the dozen values that exist as a .env on one laptop and nowhere else, because the AI that wrote the app never had to deploy it.

This is the list I walk through before a deploy, in the order that stops the most breakage. If you are shipping an app you generated with Cursor, Lovable, Bolt or v0, half of these are missing from your repository right now.

1. The public URL of the app itself

Auth emails, password resets, OAuth redirects and share links all need to know where the app lives. Generated code usually hardcodes http://localhost:3000 .

NEXT_PUBLIC_SITE_URL / VITE_APP_URL / PUBLIC_BASE_URL

Use the production domain, no trailing slash, and keep a separate value per environment.

2. Auth redirect allow-list (not an env var, but the same class of bug)

Supabase, Firebase Auth, Auth0, Clerk and Google OAuth each keep their own list of allowed callback URLs.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.