Need Assistance?

support@tutorialshub.in

Middleware Architecture

Serving Static Files (express.static)

ADVERTISEMENT
Express.js Free Lesson
5 min read
ADVERTISEMENT

To serve images, CSS stylesheets, client-side JavaScript, and PDFs, use the built-in express.static() middleware. Pass the name of the directory containing your static assets (commonly public).

You can also mount a virtual path prefix so files in public/logo.png are served at /assets/logo.png.

ADVERTISEMENT
Hi, I'm Tuby! Here to help you