Vercel preview deployments are public: how to lock them
Vercel states that a generated deployment URL is publicly accessible by default. Open Project Settings, then Deployment Protection. Turn on Standard Protection with Vercel Authentication. Then give the Preview environment its own test database and its own keys. Then delete old previews.
This guide shows how to find every preview URL and how to lock it. It also shows what each plan allows and how to check the data that previews can reach.
Why is a preview URL a problem?
A preview deployment is a full copy of your app. Vercel builds one for each push to a branch that is not the production branch. The copy runs your code, your API routes, and your environment variables for the Preview environment.
The Vercel documentation on generated URLs says that the generated URL is “publicly accessible by default.” You can make it private with Deployment Protection.
This creates four risks:
- Open pages. Anyone with the URL sees unreleased features and test content.
- Open API routes. The preview serves the same API routes as production. An unprotected route returns data to anyone.
- Real data. Many previews use the production database or a production key.
- Weak test setup. A preview can have a test login, a debug route, or relaxed rules that you would never ship.
AI tools make this worse. v0 and similar tools create many branches and many previews. Each one is a new public address. A project can have dozens of live previews after one week.
The URL is not secret. Vercel documents the pattern of the branch URL: <project-name>-git-<branch-name>-<scope-slug>.vercel.app. If a person knows your project name and your team slug, they can try common branch names such as dev, staging, or fix-login. The commit URL has a nine-character hash. It is harder to guess, but it appears in GitHub pull request comments, in logs, and in shared screenshots.
Caution: A URL that is hard to guess is not protection. Use a login.
How do I find every preview URL?
Make a list first. A preview that you forgot is a preview that stays open.
- Open the Vercel dashboard.
- Open the project.
- Open Deployments.
- Set the environment filter to Preview.
- Open each deployment. Write down its URLs.
Each preview can have more than one URL. Vercel lists the unique deployment URL and the Git branch URL. Both stay public until you protect them.
Check these other places too:
- GitHub pull request comments. The Vercel bot posts a link in each pull request. Open closed pull requests as well.
- The Vercel CLI. Run
vercel lsin the project folder to list recent deployments. - Your chat and tickets. People paste preview links to share work.
- Custom domains. You can assign a domain to a preview. Check Domains in the project settings.
Then test each URL from outside. Use a private browser window with no Vercel login. You can also use curl:
curl -s -o /dev/null -w "%{http_code}\n" https://my-app-git-dev-my-team.vercel.app/
curl -s -o /dev/null -w "%{http_code}\n" https://my-app-git-dev-my-team.vercel.app/api/users
A 200 status for a page or for an API route means that the preview is open. A protected deployment does not return your page to a stranger. It sends a login request.
Check the API route too. A page that shows a login form can still return data from /api/.... Read the guide for an unprotected v0 API route if the second request returns data.
You can also scan your own URLs with the environment exposure checker. It looks for exposed variables and files at a URL that you give it.
How do I turn on Deployment Protection?
Deployment Protection is a project setting. You choose a method and a scope.
- Open the project in the Vercel dashboard.
- Open Settings.
- Open Deployment Protection.
- Turn on Vercel Authentication.
- Select Standard Protection for the scope.
- Click Save.
The Deployment Protection documentation describes the scopes:
| Scope | What it protects |
|---|---|
| Standard Protection | All deployments except production domains |
| All Deployments | All URLs, including production domains |
| (Legacy) Standard Protection | All preview and deployment URLs, not the current production URLs |
| (Legacy) Pre-Production Deployments | Only preview URLs |
Vercel calls Standard Protection the recommended option for most projects. It is available on all plans. The option All Deployments is also available on all plans.
After you turn it on, a visitor who opens a preview must log in with Vercel. Only users with access to the deployment can view it. These users include team members, project members, and users that you grant access. A visitor without access can send an access request.
Warning: Do not turn protection off to fix a broken preview. All existing deployments become unprotected when you disable Vercel Authentication.
What does each plan allow?
Vercel states these limits at the time of writing. Check the documentation again, because plans change.
- Vercel Authentication: All plans, including Hobby.
- Standard Protection and All Deployments: All plans.
- Password Protection: Pro for $20 per month per protected project. Included on Enterprise. Not available on Hobby.
- Passport and Trusted IPs: Enterprise.
- Protection Bypass for Automation: All plans.
A Hobby team can have only one external user per account for access requests. For more outside reviewers, use a Pro plan, a shareable link, or a password.
For most solo builders, Vercel Authentication with Standard Protection is enough. It costs nothing.
How do I set it for every new project?
You can set a team default. Open the team Settings, then Deployment Protection. Choose the protection level and a method. New projects use this default. You can override it for a single project.
Do this once. A new v0 project then starts with protection on.
What breaks when I turn protection on?
Standard Protection restricts the production generated deployment URL. Code that calls VERCEL_URL or VERCEL_BRANCH_URL from the server can fail. Vercel documents the fix. Use a relative path for client requests. For server requests, use the origin of the incoming request and pass the cookie.
export async function GET(request: Request) {
const { origin } = new URL(request.url);
const headers = { cookie: request.headers.get("cookie") ?? "" };
return fetch(`${origin}/some/path`, { headers });
}
Webhooks from Stripe or GitHub to a preview URL also fail, because they cannot log in. Vercel offers Protection Bypass for Automation for this. It uses a secret in the x-vercel-protection-bypass header or in a query parameter.
Warning: Do not put a bypass secret in code that runs in the browser. Use the header for tools that can set one. A query parameter appears in logs. Store the secret in a Secret environment variable. If it leaks, regenerate it in the project settings and redeploy.
How do I give the Preview environment its own data?
Protection controls who sees the preview. It does not change what the preview can reach. If the Preview environment holds your production keys, then any team member, and any code on any branch, can reach production data.
- Open Settings, then Environment Variables.
- Look at each variable that has the Preview environment.
- Compare the Preview value with the Production value.
- Create a separate test database. For Supabase, create a second project.
- Create test keys for Stripe, and use a low spend limit for AI keys.
- Set the Preview value to the test value.
- Set the type to Secret for each key.
You can set a variable for one Preview branch only. Vercel states that branch-specific variables override the general Preview variables with the same name. You do not need to copy all variables to each branch.
Vercel also has a team policy to enforce this. Owners can enable Require Separate Values under Separate Production Secret Values in the team Security settings. Then each Secret must use a different value in Production than in Preview.
For Stripe, use the test mode keys in Preview. Never put a sk_live_ key in the Preview environment.
For Supabase, the test project needs the same schema and RLS policies as production. Without RLS, the test project is open too. Run the same checks on it. Use the Supabase RLS checker on the preview URL.
After you change a variable, redeploy. Vercel states that a change applies only to new deployments. An old preview keeps the old values. This is another reason to delete old previews, as the next sections show.
What if my preview shows missing variables?
v0 and Vercel previews can fail with errors such as “Supabase URL or Anon Key is missing”. A Vercel community thread from February 2026 describes this in a v0 preview. The reporter says the preview build ran without the variables, while production worked. Vercel staff said the team was working on the preview issue. The thread does not give a confirmed cause.
Do not fix this by copying the production values into a public preview. Add test values to the Preview environment instead.
What about NEXT_PUBLIC_ values in preview?
Next.js puts NEXT_PUBLIC_ variables into the JavaScript that the browser downloads. Vercel states that the build inlines them. Anyone who opens the preview can read them.
This matters for previews in two ways. First, a preview with no protection shows these values to everyone. Second, a preview that uses the production values shows the production values.
- Open the preview in a private window.
- Open the browser developer tools.
- Search the loaded JavaScript files for
NEXT_PUBLIC_,eyJ, andsk-. - Check each value that you find.
A Supabase anon key in the bundle is normal. It is safe only when RLS is on for every table. A Supabase service_role key, a Stripe secret key, or an OpenAI key in the bundle is a leak. Never use the NEXT_PUBLIC_ prefix for a real secret. If you find one, replace the key at its provider, as the Supabase service role key guide shows. Then check your Git history with the GitHub secret alert guide.
Also check source maps. A preview can serve .map files that show your original code. Vercel offers Protected Source Maps to hide them behind login. Use it for the production site too.
How do I delete old previews?
Old previews stay live until the retention policy removes them. Vercel states that a generated URL works as long as the deployment retention policy allows. An old preview can hold old code with old bugs and old keys.
- Open Deployments in the project.
- Filter by Preview.
- Open the menu of each old deployment.
- Select Delete.
- Repeat for each project.
Delete previews for branches that you merged or closed. Delete previews from before you added protection.
Use the retention setting to limit the time. Open Settings, then Deployment Retention. Choose a shorter period for preview deployments. Check the options that your plan gives.
After a key rotation, an old preview that still holds the old key breaks or, worse, still works with a key you wanted to remove. Delete it.
Also check for preview links that you shared. Shareable links and bypass secrets give access to protected deployments. Open Deployment Protection and revoke links and secrets that you do not need.
How do I stop this in the future?
Make protection the default, not a task.
- Set the team default to Standard Protection with Vercel Authentication.
- Keep production keys out of the Preview environment.
- Use a test database for every Preview deployment.
- Mark every key as a Secret.
- Check each new v0 project for the Deployment Protection setting.
- Delete merged branches and their previews each week.
- Require a login check in every API route, even on previews.
Read the v0 security checklist for more checks. The guide on rotating Vercel environment variables covers keys that sat in Vercel after the April 2026 incident.
When should I get help?
Get help from a security engineer if one of these is true:
- A preview used your production database, and the preview was public.
- You see requests in the logs from addresses that you do not know.
- A preview held a live payment key or a
service_rolekey. - You cannot list all deployments across your projects.
- You must tell users or a regulator.
Keep the deployment list, the log files, and the times of each change. A clear record saves time.
Common questions
Is a Vercel preview URL public by default?
Which Deployment Protection setting do I need?
Can a stranger guess my preview URL?
Does protection also lock my production site?
Does a preview need real data?
Test your preview urls
A VibeEval scan tests a URL that you give it from outside. Scan a preview URL to see if it answers without a login and if its API returns data.
14-day free trial · Cancel anytime