I had the same issue yesterday and solved it.
So first node uses folder path to get files.
That means that if you're at http://localhost:3000/
you are at the root of your directory. also you can access your stylesheet via http://localhost:3000/public/css/style.css
.
But, you can modify the path using routes and express.static()
.
You may have an url which is http://localhost:3000/user/index
. So he is seeking for the css file such as http://localhost:3000/user/public/css/style.css
which does not exist.
the solution might be to use different route files like this :
app.use('/', indexRouter);
app.use('/users', usersRouter);