Closed galaxine-senpai closed 7 months ago
__dirname
does not have trailing slash, so your problem is the string concatenation.
You can use path.join
, which will build a path from segments by inserting platform-specific directory separator between the segments.
// const path = require("node:path");
app.get("/robots.txt", function (req, res) {
res.sendFile(path.join(__dirname, "robots.txt"));
});
Yep, its a path construction issue.
OS: Debian GNU/Linux 11 (bullseye) aarch64 Bug: .get() (specifically when using robotx.txt) trys to grab /home/xxxxx/microwavebot-webrobots.txt (I presume due to the folder name)
Code snippet:
Expected result: It grabs robots.txt from the current directory Actual result: it attemps to grab from the home directory of the user
Note: I am entirely unsure if this is due to something I did that I don't remember or my OS or maybe even an actual bug