Description/Context
next.learn.mit.edu is the raw Kubernetes-hosted NextJS backend that Fastly proxies for learn.mit.edu. It should never be directly indexed by search engines — all public traffic and crawling should go through learn.mit.edu (the Fastly-fronted canonical URL).
Currently the app's robots.ts route handler uses the MITOL_NOINDEX environment variable to decide what to serve:
MITOL_NOINDEX=true → Disallow: / (used in CI and QA environments)
MITOL_NOINDEX=false → Allow: / with specific disallows (used in production)
Because production sets MITOL_NOINDEX=false, the robots.txt served at next.learn.mit.edu/robots.txt currently says Allow: / — making the domain crawlable. Google is actively indexing pages at next.learn.mit.edu as a result.
The ol-infrastructure repo is addressing this at the HTTP header level by injecting X-Robots-Tag: noindex, nofollow at the Traefik Gateway for next.learn.mit.edu (with Fastly stripping that header before forwarding responses to learn.mit.edu users). This issue covers the complementary robots.txt fix in the app itself.
Plan/Design
Modify frontends/main/src/app/robots.ts to check whether the incoming request's host matches the canonical public origin (NEXT_PUBLIC_ORIGIN, e.g. learn.mit.edu). If the host does not match the canonical origin, serve a Disallow: / robots.txt regardless of the MITOL_NOINDEX value.
Reference:
Description/Context
next.learn.mit.eduis the raw Kubernetes-hosted NextJS backend that Fastly proxies forlearn.mit.edu. It should never be directly indexed by search engines — all public traffic and crawling should go throughlearn.mit.edu(the Fastly-fronted canonical URL).Currently the app's
robots.tsroute handler uses theMITOL_NOINDEXenvironment variable to decide what to serve:MITOL_NOINDEX=true→Disallow: /(used in CI and QA environments)MITOL_NOINDEX=false→Allow: /with specific disallows (used in production)Because production sets
MITOL_NOINDEX=false, therobots.txtserved atnext.learn.mit.edu/robots.txtcurrently saysAllow: /— making the domain crawlable. Google is actively indexing pages atnext.learn.mit.eduas a result.The
ol-infrastructurerepo is addressing this at the HTTP header level by injectingX-Robots-Tag: noindex, nofollowat the Traefik Gateway fornext.learn.mit.edu(with Fastly stripping that header before forwarding responses tolearn.mit.eduusers). This issue covers the complementaryrobots.txtfix in the app itself.Plan/Design
Modify
frontends/main/src/app/robots.tsto check whether the incoming request's host matches the canonical public origin (NEXT_PUBLIC_ORIGIN, e.g.learn.mit.edu). If the host does not match the canonical origin, serve aDisallow: /robots.txt regardless of theMITOL_NOINDEXvalue.Reference:
NEXT_PUBLIC_ORIGINis already available in the environment (https://learn.mit.eduin production)robots.tsroute handler has access to request headers vianext/headers