Preview noindex
Vercel and Next.js: robots.txt, preview noindex, and why staging leaks
A *.vercel.app deployment URL sends x-robots-tag noindex by default. A custom branch domain does not, unless you add the header.
The short answer
If a *.vercel.app deployment URL says noindex, that is Vercel's default for preview deployments and for production deployments you open through their unique deployment URL, including outdated production deployments. Your production domain is the URL Google should index. If a staging site on a custom domain assigned to a Git branch is in Google, Vercel did not add noindex there. Add the header yourself.
Vercel's response headers docs say the x-robots-tag header is present only on preview deployments, and on production deployments that you request through their unique deployment URL instead of a production domain. That includes outdated production deployments, which stay available at their unique deployment URL after you promote a new deployment. Vercel says it adds the header automatically with a value of noindex "to prevent search engines from crawling your Preview Deployments and outdated Production Deployments, which could cause them to penalize your site for duplicate content."
Check which URL you are looking at
The same project can answer on three different hosts. Vercel documents which of them get x-robots-tag: noindex.
- Production domain. The domain you want in Google, such as
example.com. Vercel does not add this header on the production domain. - Unique deployment URL. A
*.vercel.appaddress for a preview deployment, or for a production deployment you request through that unique URL, including an outdated production deployment. Vercel addsx-robots-tag: noindex. - Branch domain. A custom domain assigned to a Git branch, such as
staging.example.com. Vercel does not add the header when a preview is served from that domain.
To check whether a deployment sends the header, request it with curl and look for x-robots-tag: noindex. This is the command from Vercel's docs:
Example
curl -I https://your-preview-url.vercel.app
Vercel also says these response headers can be viewed from the browser's dev tools.
You can prevent the header from being added to a preview deployment by assigning a production domain to it, or by disabling it manually in vercel.json. Vercel lists both.
The production domain says noindex
If the production domain says noindex, that is not the header Vercel adds automatically. Vercel adds x-robots-tag: noindex on preview deployments and on production deployments requested through their unique deployment URL, not on the production domain.
Check these places:
- A noindex meta tag, or robots metadata, in the HTML. Excluded by noindex tag is the Search Console status for that signal. noindex explained covers the meta tag and the X-Robots-Tag header.
- A header set in
next.config,vercel.json, or middleware.
Stop a staging domain leaking into Google
Vercel does not add the header when you serve a preview from a custom domain assigned to a Git branch, such as staging.example.com. Search engines can index that domain unless you add the header yourself.
In Next.js, Vercel says to return the header from next.config.js only when VERCEL_ENV is preview. This snippet is from Vercel's response headers docs:
Example
module.exports = {
async headers() {
if (process.env.VERCEL_ENV !== 'preview') {
return [];
}
return [
{
source: '/:path*',
headers: [{ key: 'X-Robots-Tag', value: 'noindex' }],
},
];
},
};For other frameworks, Vercel says to add the header in vercel.json and scope it to the branch domain with a has condition of type host. This snippet is from the same Vercel docs:
Example
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"headers": [
{
"source": "/(.*)",
"has": [{ "type": "host", "value": "staging.example.com" }],
"headers": [{ "key": "X-Robots-Tag", "value": "noindex" }]
}
]
}Use your branch domain in place of staging.example.com. Redeploy, then run the same curl -I check against the custom domain and look for x-robots-tag: noindex. Vercel says search engines remove pages that are already indexed the next time they crawl them.
noindex only asks search engines not to index a page. Anyone with the URL can still open the deployment. To control who can view a preview, use Deployment Protection. That is also from Vercel's response headers docs.
robots.txt in Next.js
robots.txt is a separate file from the x-robots-tag header. Next.js docs say to add or generate a robots.txt file in the root of the app directory.
A static file is app/robots.txt. This is the static example from those docs, including the sitemap line. The host in the example is acme.com. Use your production domain.
Example
User-Agent: * Allow: / Disallow: /private/ Sitemap: https://acme.com/sitemap.xml
Or add app/robots.ts (or app/robots.js) that returns a MetadataRoute.Robots object. The fields in this example are rules, userAgent, allow, disallow, and sitemap. This is the TypeScript example from the same Next.js docs:
Example
import type { MetadataRoute } from 'next'
export default function robots(): MetadataRoute.Robots {
return {
rules: {
userAgent: '*',
allow: '/',
disallow: '/private/',
},
sitemap: 'https://acme.com/sitemap.xml',
}
}Next.js says you can customize how individual search engine bots crawl your site by passing an array of user agents to the rules property.
Next.js says robots.js is a special Route Handler that is cached by default unless it uses a Request-time API or dynamic config option. The same page shows app/robots.ts as the TypeScript file.
robots.txt controls crawling, not indexing. A page blocked in robots.txt cannot show Google its noindex. "Indexed, though blocked by robots.txt" explains that case, and robots.txt explained for beginners is a short tour of the file.
Run the free check
Paste your production URL into the free check. It is free, no sign-up. How to check if Google can index my page covers what a public check can see before Search Console.
The check fetches the URL you paste with a browser user agent and follows redirects. It reads the X-Robots-Tag header on that browser response. When the content type looks like HTML or XML, or the body starts with <, it also reads the meta robots tag and the googlebot meta tag. The report flags noindex when that header contains noindex. When the page is read that way, noindex or none on the meta robots tag, the googlebot meta tag, or the header also flags it. A googlebot meta tag that contains index, and does not contain noindex, is not treated as noindex. The check does not read X-Robots-Tag from a second fetch as Googlebot.
It fetches /robots.txt on the final host with the Googlebot user agent. When that response is a success status, it parses the Allow and Disallow rules and decides whether the final URL's path and query are allowed for Googlebot and for each other crawler token in the check. When Googlebot is blocked, the report names the matching rule.
FAQ
Why does my Vercel site say noindex?
If the address is a preview deployment, or a production deployment opened on its unique deployment URL, Vercel adds x-robots-tag: noindex on its own. That includes outdated production deployments. The production domain does not get that automatic header. If the production domain still says noindex, check a noindex meta tag, robots metadata, or a header in next.config, vercel.json, or middleware.
How do I add robots.txt in Next.js?
Put a static robots.txt in the root of the app directory, or add app/robots.ts that returns a MetadataRoute.Robots object with rules, userAgent, allow, disallow, and sitemap. Next.js documents both, including per-user-agent rules as an array on rules. The docs say robots.js is cached by default unless it uses a Request-time API or dynamic config option.
Why is my staging or preview site showing in Google?
A unique deployment URL gets x-robots-tag: noindex from Vercel. A custom domain assigned to a Git branch, such as staging.example.com, does not. Vercel says search engines can index that domain unless you add the header yourself. After you redeploy, pages that are already indexed drop out the next time search engines crawl them.
Related
A firewall that blocks a crawler is a different problem from this header. See Is Vercel's firewall blocking GPTBot or ClaudeBot?. A page that looks finished in the browser and empty in the HTML is covered in Lovable, v0, and Bolt pages that Google never sees.
- Excluded by noindex tag
- noindex explained
- robots.txt explained for beginners
- "Indexed, though blocked by robots.txt"
- How to check if Google can index my page
Sources (fetched 23 Nov 2026)
- Vercel, Response headers (
x-robots-tagon preview and unique deployment URLs, the branch-domain exception, both snippets, redeploy, and Deployment Protection): https://vercel.com/docs/headers/response-headers - Next.js, robots.txt (static
app/robots.txt,app/robots.ts,MetadataRoute.Robots, sitemap, per-user-agent rules, and therobots.jscache note): https://nextjs.org/docs/app/api-reference/file-conventions/metadata/robots