In my case, it was necessary to specify auxiliary directories, as well as the main "public" static directory, for example:
app.use(express.static(path.join(__dirname, 'public'))); app.use('/public/uploads', express.static(path.join(__dirname, '/public/uploads')));
Also after the game, I found that it doesn’t matter if the “public” static directory was declared as “/ public” or “public” (with or without a leading slash).
However, it did matter if I skipped the leading slash from the subdirectories, i.e. it gave me 404:
app.use('public/uploads', express.static(path.join(__dirname, 'public/uploads')));
but it worked fine:
app.use('/public/uploads', express.static(path.join(__dirname, '/public/uploads')));
And, of course, an old chestnut, certifying that the permissions are correctly set in the directory!
source share