Skip to content

Commit

Permalink
Send the right robots.txt from the production domain. (#53822)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>
  • Loading branch information
chrisgavin and heiskr authored Jan 9, 2025
1 parent 8f19ef9 commit 7c8e544
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/frame/middleware/robots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ export default function robots(req: ExtendedRequest, res: Response, next: NextFu

defaultCacheControl(res)

const host = req.get('x-host') || req.get('x-forwarded-host') || req.get('host')

// only include robots.txt when it's our production domain and adding localhost for robots-txt.js test
if (req.hostname === 'docs.github.com' || req.hostname === '127.0.0.1') {
if (
host === 'docs.github.com' ||
req.hostname === 'docs.github.com' ||
req.hostname === '127.0.0.1'
) {
return res.send(defaultResponse)
}

Expand Down

0 comments on commit 7c8e544

Please sign in to comment.