Skip to content

Commit c6fa0fe

Browse files
authored
Disallow robot crawlers outside of Prod (#2381)
1 parent 318aacc commit c6fa0fe

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

frontends/main/src/app/robots.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,29 @@ invariant(process.env.NEXT_PUBLIC_ORIGIN, "NEXT_PUBLIC_ORIGIN must be defined")
55
const BASE_URL: string = process.env.NEXT_PUBLIC_ORIGIN
66

77
export default function robots(): MetadataRoute.Robots {
8-
const sitemap =
9-
process.env.MITOL_NOINDEX === "false"
10-
? `${BASE_URL}/sitemaps/sitemap-index.xml`
11-
: undefined
12-
return {
13-
rules: {
14-
userAgent: "*",
15-
allow: "/",
16-
disallow: [
17-
"/dashboard/",
18-
"/learningpaths/",
19-
"/onboarding/",
20-
"/cart/",
21-
"/program_letter/",
22-
],
23-
},
24-
sitemap,
8+
const shouldIndex = process.env.MITOL_NOINDEX === "false"
9+
10+
if (shouldIndex) {
11+
return {
12+
rules: {
13+
userAgent: "*",
14+
allow: "/",
15+
disallow: [
16+
"/dashboard/",
17+
"/learningpaths/",
18+
"/onboarding/",
19+
"/cart/",
20+
"/program_letter/",
21+
],
22+
},
23+
sitemap: `${BASE_URL}/sitemaps/sitemap-index.xml`,
24+
}
25+
} else {
26+
return {
27+
rules: {
28+
userAgent: "*",
29+
disallow: "/",
30+
},
31+
}
2532
}
2633
}

0 commit comments

Comments
 (0)