control search engine visibility

This commit is contained in:
LouisLam
2021-08-09 18:16:27 +08:00
parent ddcfa558f7
commit b69185ee9e
4 changed files with 16 additions and 10 deletions

View File

@@ -88,16 +88,26 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
// Normal Router here
app.use("/", express.static("dist"));
// Robots.txt
app.get("/robots.txt", async (_request, response) => {
let txt = "User-agent: *\nDisallow:";
if (! await setting("searchEngineIndex")) {
txt += " /";
}
response.setHeader("Content-Type", "text/plain");
response.send(txt);
});
// Basic Auth Router here
// Prometheus API metrics /metrics
// With Basic Auth using the first user's username/password
app.get("/metrics", basicAuth, prometheusAPIMetrics())
app.get("/metrics", basicAuth, prometheusAPIMetrics());
app.use("/", express.static("dist"));
// Universal Route Handler, must be at the end
app.get("*", function(_request, response) {
app.get("*", async (_request, response) => {
response.send(indexHTML);
});