spike: Serve robots.txt#21623
Conversation
🚨 PR Title Validation Failed 🚨Your pull request title does not follow the required format. Please update it to match the expected pattern: Expected format: Allowed Types
Example of a valid PR title✅ ❌ Merge is blocked until the PR title is corrected. |
🚨 PR Title Validation Failed 🚨Your pull request title does not follow the required format. Please update it to match the expected pattern: Expected format: Allowed Types
Example of a valid PR title✅ ❌ Merge is blocked until the PR title is corrected. |
1d30fef to
6219cd6
Compare
🚨 PR Title Validation Failed 🚨Your pull request title does not follow the required format. Please update it to match the expected pattern: Expected format: Allowed Types
Example of a valid PR title✅ ❌ Merge is blocked until the PR title is corrected. |
6219cd6 to
5dae578
Compare
🚨 PR Title Validation Failed 🚨Your pull request title does not follow the required format. Please update it to match the expected pattern: Expected format: Allowed Types
Example of a valid PR title✅ ❌ Merge is blocked until the PR title is corrected. |
…engine
Previously, requests to /robots.txt fell through to the Angular SSR engine
and returned HTML with Content-Type: text/html, breaking all crawlers.
- Adds createRobotsTxtHandler() to @spartacus/setup/ssr — returns an
Express RequestHandler that serves plain text with Cache-Control headers,
or null when disabled (enabled: false)
- Ships DEFAULT_ROBOTS_TXT_CONTENT with rules for traditional crawlers and
major AI crawlers (GPTBot, ClaudeBot, OAI-SearchBot, PerplexityBot,
Google-Extended, Claude-SearchBot, ChatGPT-User)
- Accepts RobotsTxtOptions.content for full merchant override
- Route is registered before static assets and the Angular SSR catch-all
- Updates the add-ssr schematic template so new projects get it wired automatically
- Adds unit tests and SSR E2E test
Content Signals and per-bot config toggles are out of scope for this spike.
CSR-only deployments must serve robots.txt via static hosting / CDN.
5dae578 to
b438e19
Compare
🚨 PR Title Validation Failed 🚨Your pull request title does not follow the required format. Please update it to match the expected pattern: Expected format: Allowed Types
Example of a valid PR title✅ ❌ Merge is blocked until the PR title is corrected. |
🚨 PR Title Validation Failed 🚨Your pull request title does not follow the required format. Please update it to match the expected pattern: Expected format: Allowed Types
Example of a valid PR title✅ ❌ Merge is blocked until the PR title is corrected. |
Problem
Requests to /robots.txt fall through to the Angular SSR engine, which returns server-rendered HTML with Content-Type: text/html. This is a hard failure for all crawlers — traditional and AI alike.
Solution
Add an explicit Express route that intercepts /robots.txt before the Angular SSR catch-all and serves a plain text response.
Changes
Usage
Custom content override:
Disable entirely:
createRobotsTxtHandler({ enabled: false }) // returns null, route not registeredOut of scope
Content Signals, per-bot config toggles, and CSR static asset support are deferred to follow-up tasks.
Test plan