node-static-auth provides a static file server for Node.js, integrating features like Basic authentication, access file logging with rotation, and custom error pages (401, 404, 500). It supports both HTTP and HTTPS, including an HTTP listener for automatic redirects to HTTPS, and historically offered experimental HTTP/2 support for Node.js versions 9.x and above. The package bundles popular modules like `node-static`, `basic-auth`, `morgan`, and `rotating-file-stream` to deliver its functionality. As of its last known stable release (1.0.6), it caters to older Node.js environments (engines >= 0.10.0) and has not seen active development in many years, making it unsuitable for modern applications requiring current security standards or active maintenance.
npm install node-static-authVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes and starts an HTTPS static server with Basic authentication and access logging, demonstrating common configuration options.
Migrate to a actively maintained static file server solution like `serve-static`, `express.static`, or `sirv` combined with modern authentication and logging middleware.
If custom error pages are critical, ensure `server.http2` is set to `false` in the configuration.
Avoid using the HTTP/2 feature. If HTTP/2 is required, use a modern, actively maintained server framework that provides robust HTTP/2 support.
Always enforce HTTPS (`ssl.enabled: true`) when using Basic Auth. For new projects, consider modern authentication mechanisms like OAuth2 or token-based authentication with updated libraries.
Ensure your project uses CommonJS (`require()`) or use a build tool like Webpack/Rollup to transpile CommonJS modules into ESM if absolutely necessary, though this is not recommended for an abandoned package.
Ensure your Node.js file is treated as CommonJS (e.g., `.js` file without `"type": "module"` in `package.json`, or explicitly `.cjs` extension). This package does not support ESM imports.
Run `npm install node-static-auth` in your project directory.
This issue is indicative of the package's age. It's strongly recommended to migrate to an actively maintained solution. As a temporary workaround for development, you might try `NODE_OPTIONS='--openssl-legacy-provider' node your-app.js`, but this is not suitable for production.