I don’t think that’s necessary because it works perfectly fine and also, the documentation for static files in Express (Serving static files in Express) already has such an example, and in that
For example, use the following code to serve images, CSS files, and JavaScript files in a directory named public :
We’re in the process of updating hello-express with the latest versions of modules and some updated code structure, so this feedback is right on time! @J-Tech-Foundation and @joe, I’m trying to understand what the benefits of adding __dirname or the leading / are, can you share some more details?
__dirname is ( and i think, have not hopped on the actual editor today, so my mind is blank ) /user/app/
which, without sudo, or root, “/” will equal to that of the base directory of the project, that should explain all
oh, ~/ is the same as / in things like fs and express, so, yea…
all i can explain
It’s not a huge deal for the average user of Glitch, but it can be dangerous for those who export their code to put it on their own server (and run it with PM2, for example), because you can end up serving a directory that you didn’t intend to. This is probably why the original author of the hello-express template used __dirname for response.sendFile(...). I think they just forgot to add it for the express.static(...) call.