Skip to content

Prevent next.learn.mit.edu from being indexed via robots.txt #3446

Description

@blarghmatey

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=trueDisallow: / (used in CI and QA environments)
  • MITOL_NOINDEX=falseAllow: / 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions