Issue with express static middleware and subdirectory
问题 I have this folder as my website structure -views -index -post -public -css -js -images -app.js But a post link can be: mywebsite.com/posts/a-link-example So, when I use express static middleware like this: app.use(express.static(__dirname + '/public')); it only works in pages without a "subdirectory" like example.com/home example.com/contact but not on example.com/posts/post-name I can use of course: app.use('/posts, express.static(__dirname + '/public')); but is there a better way to do it?