Serving Static Assets with Express
By Flavio Copes
Learn how to serve static assets like images and CSS in Express with the express.static() middleware, exposing a public folder at the root URL of your app.
~~~
It’s common to have images, CSS and more in a public subfolder, and expose them to the root level:
const express = require('express')
const app = express()
app.use(express.static('public'))
/* ... */
app.listen(3000, () => console.log('Server ready'))
If you have an index.html file in public/, that will be served if you now hit the root domain URL (http://localhost:3000)
~~~
Related posts about express: