From 16a0af8fd48197a2941930f2eb44da6fd16bf8f2 Mon Sep 17 00:00:00 2001 From: Bentroen <29354120+Bentroen@users.noreply.github.com> Date: Tue, 16 Jun 2026 01:14:44 -0300 Subject: [PATCH] chore: add dynamic `robots.txt` generation Prevents web crawling on non-production deployments. --- apps/frontend/src/app/robots.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 apps/frontend/src/app/robots.ts diff --git a/apps/frontend/src/app/robots.ts b/apps/frontend/src/app/robots.ts new file mode 100644 index 00000000..ceb96f91 --- /dev/null +++ b/apps/frontend/src/app/robots.ts @@ -0,0 +1,25 @@ +import { MetadataRoute } from 'next'; + +export default function robots(): MetadataRoute.Robots { + // Check if the current deployment is Production + const isProd = process.env.NODE_ENV === 'production'; + + if (isProd) { + return { + rules: { + userAgent: '*', + allow: '/', + disallow: ['/api/', '/admin/'], // Block search engines from sensitive paths + }, + sitemap: 'https://noteblock.world', + }; + } + + // Block ALL crawling on Preview, Staging, and Local environments + return { + rules: { + userAgent: '*', + disallow: '/', + }, + }; +}