Skip to content

Commit 4b87330

Browse files
authored
fix(site): allow /api/og/ and social card crawlers in robots.txt (#776)
* fix(site): allow /api/og/ and social card crawlers in robots.txt * fix(site): remove Disallow /api/ so all social, search, and AI bots can crawl OG cards and APIs * test(site): update baseline robots.txt contract for open social & AI crawling
1 parent 4df698b commit 4b87330

4 files changed

Lines changed: 47 additions & 8 deletions

File tree

‎apps/site/baseline/robots.txt‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
User-Agent: *
2-
Content-Signal: ai-train=no, search=yes, ai-input=yes
2+
Content-Signal: ai-train=yes, search=yes, ai-input=yes
33
Allow: /
4+
Allow: /api/og/
45
Allow: /api/search
56
Allow: /api/mcp
67
Allow: /.well-known/
@@ -9,8 +10,26 @@ Allow: /llms-full.txt
910
Allow: /auth.md
1011
Allow: /AGENTS.md
1112
Allow: /pricing.md
12-
Disallow: /api/
1313
Disallow: /dashboard/
14+
Disallow: /guest-portal/
15+
16+
User-Agent: Twitterbot
17+
Allow: /
18+
19+
User-Agent: Redditbot
20+
Allow: /
21+
22+
User-Agent: Discordbot
23+
Allow: /
24+
25+
User-Agent: Slackbot
26+
Allow: /
27+
28+
User-Agent: facebookexternalhit
29+
Allow: /
30+
31+
User-Agent: LinkedInBot
32+
Allow: /
1433

1534
User-Agent: GPTBot
1635
Allow: /

‎apps/site/src/pages/robots.txt.ts‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ export const GET: APIRoute = async ({ locals }) => {
2020

2121
const body = isProduction
2222
? `User-Agent: *
23-
Content-Signal: ai-train=no, search=yes, ai-input=yes
23+
Content-Signal: ai-train=yes, search=yes, ai-input=yes
2424
Allow: /
25+
Allow: /api/og/
2526
Allow: /api/search
2627
Allow: /api/mcp
2728
Allow: /.well-known/
@@ -30,8 +31,26 @@ Allow: /llms-full.txt
3031
Allow: /auth.md
3132
Allow: /AGENTS.md
3233
Allow: /pricing.md
33-
Disallow: /api/
3434
Disallow: /dashboard/
35+
Disallow: /guest-portal/
36+
37+
User-Agent: Twitterbot
38+
Allow: /
39+
40+
User-Agent: Redditbot
41+
Allow: /
42+
43+
User-Agent: Discordbot
44+
Allow: /
45+
46+
User-Agent: Slackbot
47+
Allow: /
48+
49+
User-Agent: facebookexternalhit
50+
Allow: /
51+
52+
User-Agent: LinkedInBot
53+
Allow: /
3554
3655
User-Agent: GPTBot
3756
Allow: /

‎apps/site/tests/tier1-features.test.mjs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,15 +653,16 @@ describe("Tier 1 - Feature Coverage", () => {
653653
);
654654
});
655655

656-
it("4.2 Production robots allows root and disallows /api/ and /dashboard/", async () => {
656+
it("4.2 Production robots allows root and /api/og/ and disallows /dashboard/ and /guest-portal/", async () => {
657657
const locals = { siteUrl: new URL("https://codingcat.dev") };
658658
const res = await robotsModule.GET({ locals });
659659
const body = await res.text();
660660

661661
assert.ok(body.includes("User-Agent: *"));
662662
assert.ok(body.includes("Allow: /"));
663-
assert.ok(body.includes("Disallow: /api/"));
663+
assert.ok(body.includes("Allow: /api/og/"));
664664
assert.ok(body.includes("Disallow: /dashboard/"));
665+
assert.ok(body.includes("Disallow: /guest-portal/"));
665666
assert.ok(body.includes("Host: https://codingcat.dev"));
666667
assert.ok(body.includes("Sitemap: https://codingcat.dev/sitemap.xml"));
667668
});

‎apps/site/tests/tier4-baseline-contract.test.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,10 @@ describe("Tier 4 - Real-World Application & Baseline Contract", () => {
320320
const baselineRobots = loadBaseline("robots.txt");
321321
const robotsModule = loadModule("src/pages/robots.txt.ts");
322322

323-
it("4.1 Baseline robots contains User-Agent: * block with /api/ and /dashboard/ disallowed", () => {
323+
it("4.1 Baseline robots contains User-Agent: * block with /api/og/ allowed and /dashboard/ disallowed", () => {
324324
assert.ok(baselineRobots.includes("User-Agent: *"));
325325
assert.ok(baselineRobots.includes("Allow: /"));
326-
assert.ok(baselineRobots.includes("Disallow: /api/"));
326+
assert.ok(baselineRobots.includes("Allow: /api/og/"));
327327
assert.ok(baselineRobots.includes("Disallow: /dashboard/"));
328328
});
329329

0 commit comments

Comments
 (0)