How do you serve static files with Express?
Model answer
Use express.static: app.use(express.static('public')). Files in that folder are served by URL. For a built React app, serve the dist folder and add a fallback route that returns index.html for client-side routes. In production, nginx often serves static files for better performance.
Learn this topic
Express Middleware Explained: next(), Logging and express.json() in the course Node.js and Express: Build a Back End API from Scratch.
Sign in to add your own answer.