Skip to content

Commit 84bdb48

Browse files
committed
chore: do not index vercel preview deployments
1 parent 3c1f4d2 commit 84bdb48

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

next.config.mjs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const nextraConfig = withNextra({
5858
],
5959
},
6060
headers() {
61-
return [
61+
const headers = [
6262
{
6363
source: "/:path*",
6464
headers: [
@@ -89,7 +89,22 @@ const nextraConfig = withNextra({
8989
},
9090
],
9191
},
92-
]
92+
];
93+
94+
// Do not index Vercel preview deployments
95+
if (process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {
96+
headers.push({
97+
headers: [
98+
{
99+
key: 'X-Robots-Tag',
100+
value: 'noindex',
101+
},
102+
],
103+
source: '/:path*',
104+
});
105+
}
106+
107+
return headers;
93108
},
94109
redirects: async () => [
95110
...nonPermanentRedirects.map(([source, destination]) => ({

0 commit comments

Comments
 (0)