I want to make sure that they don't ask for a file in
That you can configure by using a route and then checking if he can access or not access. If you are using Express, something like this would be enough:
app.all("/specialfolder/*", function (req, res) {
// check what to do
if(returnFile) {
// send the file
} else {
// send 404 or other unauthorized codes, e.g. 403
}
});
You can configure these routes for as many folders as you want, secondly you can configure a regex to match the URLs, or you can put all sensitive information inside a single folder and then control URL routing for that — the way I did above.
Also note, that bot would still be able to access the content. It is only the user who will not be able to access the file directly. If the access has to be controlled with the Bot, then that depends on the framework you are trying to use.
Lastly, please note that you would need to write this above any other
app.use(express.static());
Because, the Node.js framework works in a pipeline, and this app.all()
will intervene and deny the access to files before public access is granted.