'express.static() unable to send static files

app.use(express.static(path.join(__dirname, "public")));

Can anyone help why this piece of code is not working...I also tried this:

app.use("/static",express.static(path.join(__dirname, "public")));

but it didn't work. And it's not like that I don't have the "public" folder or anything.

Image:https://i.stack.imgur.com/wcG2q.png



Solution 1:[1]

we can use this code app.use(express.static(__dirname)); instead of thisapp.use(express.static(path.join(__dirname, "public")));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Supratim Purkait