Server module for Hexo.
$ npm install hexo-server --save$ hexo server| Option | Description | Default |
|---|---|---|
-i, --ip |
Override the default server IP. | :: when IPv6 is available, else 0.0.0.0 (note: in most systems, :: also binds to 0.0.0.0) |
-p, --port |
Override the default port. | 4000 |
-s, --static |
Only serve static files. | false |
-l, --log [format] |
Enable logger. Override log format. | false |
-o, --open |
Immediately open the server url in your default web browser. | false |
server:
port: 4000
log: false
ip: 0.0.0.0
compress: false
cache: false
header: true
serveStatic:
extensions:
- html- port: Server port
- log: Display request info on the console. Always enabled in debug mode.
- ip: Server IP
- compress: Enable GZIP compression
- cache: Enable cache for rendered content
- This can speed up server response. However, any changes will no longer take effect in real time.
- Suitable for production environment only.
- header: Add
X-Powered-By: Hexoheader - serveStatic: Extra options passed to serve-static
hexo-server runs the server_middleware filter before starting the server. Plugins and theme scripts can register Connect middleware with it; the filter receives the app instance.
For example, to add a custom response header:
hexo.extend.filter.register("server_middleware", function (app) {
app.use(function (req, res, next) {
res.setHeader("X-Hexo-Middleware", "enabled");
next();
});
});MIT