Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/apps/web/app/robots.ts
blob: 1bc1a5fc41e4fffd854661f47ea815ff4ae7b4e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
// SPDX-License-Identifier: AGPL-3.0-or-later

import type { MetadataRoute } from "next";
import { headers } from "next/headers";

export default async function robots(): Promise<MetadataRoute.Robots> {
  const requestHeaders = await headers();
  const host =
    requestHeaders.get("x-forwarded-host") ?? requestHeaders.get("host") ?? "";
  const canonicalHost = host.split(":", 1)[0]?.toLowerCase();
  // Progmasoft OAuth and the Progmasoft Console have sign-in, consent and
  // developer pages only; none of them is a search document.
  if (
    canonicalHost === "credentials.progmasoft.com" ||
    canonicalHost === "authorize.progmasoft.com" ||
    canonicalHost === "console.progmasoft.com"
  ) {
    return { rules: [{ userAgent: "*", disallow: "/" }] };
  }
  // Each host with pages of its own names its own sitemap.
  const sitemap =
    canonicalHost === "viget.progmasoft.com" ||
    canonicalHost === "product.progmasoft.com" ||
    canonicalHost === "catch3.uk"
      ? `https://${canonicalHost}/sitemap.xml`
      : "https://progmasoft.com/sitemap.xml";
  return {
    rules: [
      { userAgent: "Googlebot", allow: "/" },
      { userAgent: "Google-Extended", allow: "/" },
      { userAgent: "OAI-SearchBot", allow: "/" },
      { userAgent: "ChatGPT-User", allow: "/" },
      { userAgent: "GPTBot", disallow: "/" },
      { userAgent: "Claude-SearchBot", allow: "/" },
      { userAgent: "Claude-User", allow: "/" },
      { userAgent: "ClaudeBot", allow: "/" },
      { userAgent: "CCBot", disallow: "/" },
      { userAgent: "Bytespider", disallow: "/" },
      { userAgent: "*", allow: "/" },
    ],
    sitemap,
  };
}