I have a logo that is residing at the public/images/logo.gif
. Here is my nodejs code.
http.createServer(function(req, res){
res.writeHead(200,
This may be a bit off-topic, since you are asking about static file serving via Node.js specifically (where fs.createReadStream('./image/demo.jpg').pipe(res)
is actually a good idea), but in production you may want to have your Node app handle tasks, that cannot be tackled otherwise, and off-load static serving to e.g Nginx.
This means less coding inside your app, and better efficiency since reverse proxies are by design ideal for this.