1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/middleware/robots.js
Grace Park 71f9433476 Robots update (#23046)
* update to allow only if docs.github.com

* update if

* update for test
2021-11-23 18:56:05 +00:00

18 lines
470 B
JavaScript

const defaultResponse = 'User-agent: *'
const disallowAll = `User-agent: *
Disallow: /`
export default function robots(req, res, next) {
if (req.path !== '/robots.txt') return next()
res.type('text/plain')
// 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') {
return res.send(defaultResponse)
}
return res.send(disallowAll)
}