From da9413930eb075f2eaedfdfd0e2b921193c626bf Mon Sep 17 00:00:00 2001 From: wearrrrr Date: Thu, 4 Apr 2024 09:24:01 -0500 Subject: [PATCH] Dynamic robots.txt file, and add sitemap.xml. --- index.js | 7 +++++ public/{robots.txt => robots-allow.txt} | 0 public/robots-deny.txt | 2 ++ public/sitemap.xml | 40 +++++++++++++++++++++++++ 4 files changed, 49 insertions(+) rename public/{robots.txt => robots-allow.txt} (100%) create mode 100644 public/robots-deny.txt create mode 100644 public/sitemap.xml diff --git a/index.js b/index.js index 026c01f..3c02560 100644 --- a/index.js +++ b/index.js @@ -145,6 +145,13 @@ app.use("/", express.static("dist/client/")); app.get("/favicon.ico", (req, res) => { res.sendFile(path.join(process.cwd(), "dist/client/favicon.svg")); }); +app.get("/robots.txt", (req, res) => { + if (req.headers.host && whiteListedDomains.includes(req.headers.host)) { + res.sendFile(path.join(process.cwd(), "dist/client/robots-allow.txt")); + } else { + res.sendFile(path.join(process.cwd(), "dist/client/robots-deny.txt")); + } +}) app.get("/search", async (req, res) => { try { const { query } = req.query; diff --git a/public/robots.txt b/public/robots-allow.txt similarity index 100% rename from public/robots.txt rename to public/robots-allow.txt diff --git a/public/robots-deny.txt b/public/robots-deny.txt new file mode 100644 index 0000000..1337562 --- /dev/null +++ b/public/robots-deny.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: * \ No newline at end of file diff --git a/public/sitemap.xml b/public/sitemap.xml new file mode 100644 index 0000000..300e40a --- /dev/null +++ b/public/sitemap.xml @@ -0,0 +1,40 @@ + + + + + + https://aluu.xyz/en/ + 2024-04-03T02:13:11+00:00 + 1.00 + + + https://aluu.xyz/en/games/ + 2024-04-03T02:13:11+00:00 + 0.80 + + + https://aluu.xyz/en/settings/ + 2024-04-03T02:13:11+00:00 + 0.80 + + + https://aluu.xyz/jp/ + 2024-04-03T02:13:11+00:00 + 1.00 + + + https://aluu.xyz/jp/games/ + 2024-04-03T02:13:11+00:00 + 0.80 + + + https://aluu.xyz/jp/settings/ + 2024-04-03T02:13:11+00:00 + 0.80 + + + + \ No newline at end of file