From 20a83b0b3baa42d3f4ccb8fe267ca979402366bf Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Fri, 19 Jun 2020 10:17:33 +0200 Subject: Fix 404 handling for google site ownership file --- webserver.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webserver.js b/webserver.js index b53d9ab..4b49412 100755 --- a/webserver.js +++ b/webserver.js @@ -159,7 +159,11 @@ app.get("/.well-known/*", function (req, res) { app.get("/google*.html", function (req, res) { const url = unescape(makeUrlSafe(req, 0)); if (url.match(/^\/google[0-9a-fA-F]*\.html$/)) { - res.sendFile(__dirname + url); + const fname = __dirname + url; + fs.exists(fname, fs.constants.R_OK, err => { + if (err) res.status(400).send("That file does not exist."); + else res.sendFile(fname); + }); } else { res.status(404).send("That file does not exist."); } -- cgit v1.2.3-70-g09d2