Choose values, then copy one format.

Module output

Node.js CommonJS and ESM include HTTP, HTTPS-only, paired-listener, and full Config settings.

CLI output

Generates the command's HTTP flags and routes HTTPS choices to the module output.

JSON output

A serializable Config object for module code or your own storage loader.

The generator runs in the browser, but node-http-server does not. Run generated CommonJS, Node.js ESM, CLI, and JSON-based module snippets in a local Node process. Browser bundles, native browser ESM, import maps, and file:// are not supported package runtime paths.

Full Config surface

Configuration

Location and host routing

Keys: root, host, port, domain, domains, and server.index. Defaults and Host-routing rules →

HTTP behavior

Keys: server.noCache, server.allowDotfiles, server.compression, server.compressionThreshold, server.brotliQuality, server.spaFallback, server.maxRequestBodyBytes, and top-level verbose. Behavior details →

Timeouts milliseconds

Keys: server.timeout, server.requestTimeout, server.headersTimeout, and server.keepAliveTimeout. Disable semantics and units →

server.timeout controls HTTP/1 socket or HTTP/2 session inactivity. The other three settings apply only to HTTP/1 requests, including HTTP/1.1 fallback over TLS. false or 0 disables a timeout. The generated snippets use false when Off is checked.

File types and restrictions

Keys: contentType and restrictedType. MIME fallback, 403, and 415 rules →

Use extension keys without a dot. contentType:false removes automatic MIME selection; served files use application/octet-stream. One MIME entry set to false rejects that extension with 415.

Logging and errors

Keys: log, logBody, logFunction, and errors. Logging → Error responses →

These fields accept plain JSON objects. Invalid objects are ignored and marked below.

JSON fields are valid.

HTTPS

Keys: https.privateKey, certificate, ca, passphrase, http2, port, and only. HTTPS requirements →

const {Server}=require('node-http-server');

const server=new Server({
    host:'127.0.0.1',
    port:8080,
    root:'./public'
});

server.deploy();
CommonJS module Ready to copy
npm install node-http-server