From 1524b9a35ddf7183c50035cfb5ded91e2e0116a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 4 Aug 2025 20:11:51 -0500 Subject: [PATCH] fix: disallow robots on non-master domains --- .github/workflows/website.yml | 2 +- packages/website/src/pages/robots.txt.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 48de729b2..082dcd8b5 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -19,7 +19,7 @@ concurrency: env: PUBLIC_WARGAMING_APPLICATION_ID: ${{ secrets.PUBLIC_WARGAMING_APPLICATION_ID }} PUBLIC_PROMOTE_OPENTEST: ${{ secrets.PUBLIC_PROMOTE_OPENTEST }} - ALLOW_ROBOTS: 'true' + ALLOW_ROBOTS: ${{ secrets.ALLOW_ROBOTS }} WOTB_GLOSSARY: ${{ secrets.WOTB_GLOSSARY }} PUBLIC_GOOGLE_TAG_MANAGER_ID: ${{ secrets.PUBLIC_GOOGLE_TAG_MANAGER_ID }} PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID: ${{ secrets.PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID }} diff --git a/packages/website/src/pages/robots.txt.ts b/packages/website/src/pages/robots.txt.ts index d37262f56..4580d71dc 100644 --- a/packages/website/src/pages/robots.txt.ts +++ b/packages/website/src/pages/robots.txt.ts @@ -1,9 +1,12 @@ import type { APIContext } from 'astro'; +const ALLOW_ROBOTS = import.meta.env.ALLOW_ROBOTS === 'true'; + export async function GET({ request }: APIContext) { const flags: Record = { 'User-agent': '*', - Allow: '/', + Allow: ALLOW_ROBOTS ? '/' : null, + Disallow: ALLOW_ROBOTS ? null : '/', space: null, Sitemap: `${new URL(request.url).origin}/sitemap-index.xml`,