From f1a8c0cabc860c5a72faeecee18dab0b0f1a379b Mon Sep 17 00:00:00 2001 From: Flummi Date: Fri, 24 Dec 2021 11:15:30 +0100 Subject: [PATCH] robots.txt --- public/robots.txt | 6 ++++++ src/inc/routes/static.mjs | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 public/robots.txt diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..2de34a4 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,6 @@ +User-agent: * +Disallow: /tag +Disallow: /user +Disallow: /audio +Disallow: /video +Disallow: /image diff --git a/src/inc/routes/static.mjs b/src/inc/routes/static.mjs index 63c8442..90f3bde 100644 --- a/src/inc/routes/static.mjs +++ b/src/inc/routes/static.mjs @@ -1,4 +1,5 @@ import path from "path"; +import { promises as fs } from "fs"; export default (router, tpl) => { router.static({ @@ -20,4 +21,11 @@ export default (router, tpl) => { dir: path.resolve() + "/public/ca", route: /^\/ca\// }); + + router.get(/^\/robots\.txt$/, async (req, res) => { + res.reply({ + type: "text/plain", + body: await fs.readFile(path.resolve() + "/public/robots.txt", "utf-8") + }); + }); };