From 9a0954e162c1d4ab63a40db35058bc2cbb0c7456 Mon Sep 17 00:00:00 2001 From: Perception Date: Thu, 18 Feb 2021 00:04:52 -0800 Subject: [PATCH] Add robots.txt Disallow all crawlers. --- site.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/site.js b/site.js index cb15353..39199dd 100644 --- a/site.js +++ b/site.js @@ -3,6 +3,11 @@ require('dotenv').config() const { send } = require('micro') const files = require('serve-handler') +const robotsTxt = +`User-agent: * +Disallow: / +` + const staticPaths = [ '/css', '/images', '/archive' ] function isStaticPath(req) { @@ -26,5 +31,6 @@ module.exports = async function(req, res) { if (isStaticPath(req)) return await files(req, res, { public: 'routes' }) let matched = match(req) if (matched) return await matched(req, res) + if (req.url === '/robots.txt') return send(res, 200, robotsTxt) return send(res, 404, { error: 'Not found' }) }