1
0
mirror of synced 2025-12-23 11:54:18 -05:00
Files
docs/middleware/robots.js
Kevin Heis c62f49aa0e Block indexing not crawling (#17044)
* Block indexing instead of crawling

* Lint

* Update deprecated-enterprise-versions.js

* Combine loops
2020-12-17 11:57:18 -08:00

22 lines
540 B
JavaScript

const defaultResponse = 'User-agent: *'
const disallowAll = `User-agent: *
Disallow: /`
module.exports = function (req, res, next) {
if (req.path !== '/robots.txt') return next()
res.type('text/plain')
// remove subdomain from host
// docs-internal-12345--branch-name.herokuapp.com -> herokuapp.com
const rootDomain = req.hostname.split('.').slice(1).join('.')
// prevent crawlers from indexing staging apps
if (rootDomain === 'herokuapp.com') {
return res.send(disallowAll)
}
return res.send(defaultResponse)
}