Why is it not recommended to serve static files from Node.js?

View other answers to this thread
Start a personal dev blog on your domain for free and grow your readership.

3.4K+ developers have started their personal blogs on Hashnode in the last one month.

Write in Markdown · Publish articles on custom domain · Gain readership on day zero · Automatic GitHub backup and more

Sandeep Panda's photo

I agree with Jan. Nginx can be really fast while serving static files because of the sendfile system call. Also your Node.js app should be used to generate dynamic content. Requests for non-dynamic resources like static files should not come to Node and clog the process. These resources should be served by Nginx.

Connor Leech's photo

interesting. For all my MEAN stack apps I use: router.get('/*', function(req, res) { res.sendFile(rootPath + 'public/index.html', { user: req.user }); }); to serve up the angular.js portion (static files). source: github.com/cleechtech/mean-starter/blob/mas..