Skip to content

Commit 16a0af8

Browse files
committed
chore: add dynamic robots.txt generation
Prevents web crawling on non-production deployments.
1 parent efd3b04 commit 16a0af8

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

apps/frontend/src/app/robots.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { MetadataRoute } from 'next';
2+
3+
export default function robots(): MetadataRoute.Robots {
4+
// Check if the current deployment is Production
5+
const isProd = process.env.NODE_ENV === 'production';
6+
7+
if (isProd) {
8+
return {
9+
rules: {
10+
userAgent: '*',
11+
allow: '/',
12+
disallow: ['/api/', '/admin/'], // Block search engines from sensitive paths
13+
},
14+
sitemap: 'https://noteblock.world',
15+
};
16+
}
17+
18+
// Block ALL crawling on Preview, Staging, and Local environments
19+
return {
20+
rules: {
21+
userAgent: '*',
22+
disallow: '/',
23+
},
24+
};
25+
}

0 commit comments

Comments
 (0)