Skip to content

Commit

Permalink
feat(security): disallow robots from crawling the API
Browse files Browse the repository at this point in the history
  • Loading branch information
missinglink authored and orangejulius committed Nov 4, 2019
1 parent 4f8c9eb commit 9dc7088
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ if( peliasConfig.api.accessLog ){

app.use( require('./middleware/headers') );
app.use( require('./middleware/cors') );
app.use( require('./middleware/robots') );
app.use( require('./middleware/options') );
app.use( require('./middleware/jsonp') );

Expand Down
9 changes: 9 additions & 0 deletions middleware/robots.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Prevent search engines from attempting to index the API
// https://developers.google.com/search/reference/robots_meta_tag#xrobotstag

function middleware(req, res, next) {
res.header('X-Robots-Tag', 'none');
next();
}

module.exports = middleware;

0 comments on commit 9dc7088

Please sign in to comment.