Answer the question
In order to leave comments, you need to log in
How to serve static server to node.js ?
there are several html and you just need to give them to the appropriate requests to the server
Answer the question
In order to leave comments, you need to log in
There are modules like node-static . You can simply implement it on express.js ... And even easier - use nginx
npm install express --save
in code
var express = require('express');
var app = express();
app.use(express.static(__dirname + '/public'));
app.listen(3000);
But it’s better not to be perverted and install nginx for statics,
here you will have both caching and gzip and a hundred times more convenient.
It makes no sense to use a node even in a test configuration as a statics server
express.static cannot be used in production due to a known problem with the lack of a queue for opening descriptors with a large number of requests, they will start to fall off. Use node-static
For gzip, use compression , you can use it separately, you can use it together with express (don't forget to put it before static).
But they said it right, it’s still better on the production side that nginx distributes the statics
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question