Where Your Secrets Live After Deploy: Vercel, Railway and Preview Environments
Your hosting platform stores the keys to your database, payments and AI providers. Mark real secrets as write-only where the platform supports it, give production its own keys that no preview or local environment shares, protect preview URLs, and be ready to rotate everything in an hour. Railway's October 2026 incident showed why that last part is not theoretical.
On this page
Most security advice for AI-built apps is about the code. This post is about the dashboard next to it, where the values live.
On Vercel: Config or Secret
Vercel now asks you to choose a type for each environment variable:
- Config values stay readable in the dashboard for team members with access. Meant for non-sensitive settings.
- Secret values are write-only after saving. Nobody can read them back from the dashboard or API, including you. To change one you enter a new value.
Variables created under the older "Sensitive" option are treated as Secret. A saved Secret cannot be converted to Config, and Vercel's documentation says Secrets are now allowed in the Development environment too, which the old Sensitive type did not support.
What should be Secret: database URLs, the Supabase secret key, Stripe secret and webhook keys, LLM provider keys, auth signing secrets, SMTP passwords. In short, anything where reading the value is enough to act as you.
What can be Config: feature flags, public URLs, and anything prefixed NEXT_PUBLIC_. Those are compiled into browser code anyway, so hiding them in the dashboard protects nothing. If a value with that prefix feels like it should be Secret, the real problem is the prefix. See secret keys in the frontend.
Why it matters: a readable value can be copied by any team member, by a compromised team account, or by an integration with API access. A write-only value cannot. Vercel also redacts Secret values of 32 characters or more when they show up in build logs.
One thing a Secret does not protect against: your own code. Anything running in the deployment can read its environment and print it. Which brings us to previews.
Preview deployments are real deployments
Every pull request gets a live URL running that branch's code with the Preview environment's variables. Three consequences:
Previews should not hold production keys. If Preview shares the production database URL and Stripe live key, then any branch, including an experiment generated by an agent in ten minutes, runs against real customers and real money. Use a separate database (or a Supabase branch), Stripe test keys and a separate LLM key with a low spend limit.
Vercel has a team policy for this, "Separate Production Secret Values" in Security settings. When enabled, a Secret must use a different value in Production than in other environments.
Preview URLs should not be public. Without protection, anyone with the link can use the preview. Previews are also where debug routes and half-finished admin pages live. Turn on Deployment Protection so previews require a login.
Code from outside your team is code with your keys. If external contributors can open pull requests that build with your Preview variables, their code can read those variables. Require approval before building forks.
The same three rules apply on Netlify, Render, Cloudflare Pages and Railway, under different names.
Railway, October 2026: when the platform is the leak
On October 21, 2026, Railway disclosed unusual activity in the systems that store customer environment variables and asked every customer to rotate their secrets. Its incident report, published on November 10, said an attacker had decrypted environment variables for a subset of workspaces, at most 1.85% of them. Press coverage of the report put fraudulent AI usage run up on stolen keys at about $740,000.
You can do everything right in your own code and still be in that 1.85%. Three lessons hold for any host:
Rotation happens at the provider. Editing the variable in your hosting dashboard changes what your app uses. The old key keeps working until you revoke it at Stripe, OpenAI, Supabase or wherever it came from.
Know your inventory before you need it. Keep a list of every secret: what it is, where it is issued, where it is used, how to rotate it. An hour of rotation with a list is a day of archaeology without one.
Limit what a stolen key can do. Restricted Stripe keys instead of the full secret key. Database users with only the rights the app needs. Hard monthly budgets on LLM keys, so the worst case is a number you chose. We cover that in no cap on LLM API spend.
A short pre-launch list
- Every real secret is stored as write-only (Secret on Vercel, the equivalent elsewhere).
- Production values are not reused in preview, staging or local
.envfiles. - Preview deployments require login.
- No secret has a browser-exposed prefix. Search the build output to confirm.
- Team access is current. Former contractors are removed from the hosting team and the git organisation.
- Two-factor authentication is on for the hosting account, the git host and the domain registrar.
- You have a written list of secrets and have rotated one end to end as a rehearsal.
- Spend limits and usage alerts are set at each paid provider.
The code side of the same job is in our security checklist for vibe-coded apps, and leaked history is covered in keys committed to GitHub. If you would like someone to review your deployment setup along with the code, that is part of our app rescue and security audit.
