use express.static middleware to serve static css, html and js (client side) files -- directly from their URIs
below indicates the public subdirectory in main appication directory contains the static files. NOTE: this is in the www.js file in a WebStorm IDE based app
app.use(express.static('public'))
Now, you can load the files that are in the
public
directory: (assuming listing at port 3000)http://localhost:3000/images/kitten.jpg http://localhost:3000/css/style.css http://localhost:3000/js/app.js http://localhost:3000/images/bg.png http://localhost:3000/hello.html
Express looks up the files relative to the static directory, so the name of the static directory is not part of the URL.