http-serve is a command-line HTTP server that builds upon the foundational `http-server` package, enhancing it with key features such as gzip compression and a configurable fallback mechanism for nonexistent routes (404s). It also includes built-in HTTPS support, making it a robust solution for both local development and front-end testing environments. The current stable version is 1.0.1, indicating a mature yet focused tool. As a CLI utility, its release cadence is typically driven by new feature additions, bug fixes, or dependency updates. Its primary differentiators lie in its zero-configuration approach, ease of use for quick static file serving, and the added capabilities for gzipped assets and Single Page Application (SPA) routing compared to basic HTTP servers.
npm install http-serveVerified import paths — ran on the pinned version, not inferred.
Sets up a minimal static site, installs `http-serve` locally, and runs it via an `npm` script on port 8080 with gzip, a 404 fallback, and auto-opens in a browser.
Manually gzip your static assets (e.g., `gzip -k public/app.js` to create `public/app.js.gz`) and ensure the gzipped versions exist alongside the original files.
Always specify the directory you intend to serve, e.g., `http-serve ./dist` or `http-serve .`.
Generate or obtain a valid `cert.pem` and `key.pem` pair and specify their paths: `http-serve . --ssl --cert ./cert.pem --key ./key.pem`. For local development, be prepared to accept browser warnings for self-signed certs.
Review the documentation for `http-serve` specifically to understand its unique options and behaviors, especially if migrating from or comparing against `http-server`.
Install globally: `npm i -g http-serve`. Or run locally using `npx`: `npx http-serve .`. Or add a script to `package.json` and run with `npm run <script-name>`.
Use a different port number with the `-p` flag, e.g., `http-serve . -p 3000`. Alternatively, identify and terminate the process currently using port 8080.
Ensure that `cert.pem` and `key.pem` files are valid and correctly specified via `--cert` and `--key`. If using self-signed certificates for local development, you may need to manually trust them in your browser's security settings.
Verify that gzipped versions of your files exist (e.g., `app.js.gz` for `app.js`). Use `gzip -k` to create them without deleting originals. Ensure your browser is configured to accept gzip encoding.
No dependency data recorded yet.