Registry / http-networking / node-static-auth

node-static-auth

JSON →
library1.0.6jsnpmunverified

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-auth
INSTALL
IMPORT
SIG · NODE-STATIC-AUTH
N
node-static-auth
http-networkingjavascriptv1.0.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NodeStaticAuth
const NodeStaticAuth = require('node-static-auth');
import NodeStaticAuth from 'node-static-auth';
This package is CommonJS-only, reflecting its age. Direct ESM `import` statements will fail.

This quickstart initializes and starts an HTTPS static server with Basic authentication and access logging, demonstrating common configuration options.

const NodeStaticAuth = require('node-static-auth'); // IMPORTANT: Replace 'path-to-public-directory' with the actual path to your static files. // For example, if your static files are in a 'public' folder in the project root: // const PUBLIC_DIR = path.join(process.cwd(), 'public'); // Ensure 'public' directory exists and contains 'index.html', 'your-forbidden.html', etc. const config = { nodeStatic: { root: 'path-to-public-directory', // e.g., 'public' options: { indexFile: 'your-index.html' // e.g., 'index.html' }, customPages: { forbidden: 'your-forbidden.html', // e.g., '401.html' notFound: 'your-not-found.html', // e.g., '404.html' error: 'your-error.html' // e.g., '500.html' } }, server: { port: 3001, http2: false, // Set to true if running Node >= 9.x, but note limitations ssl: { enabled: true, httpListener: 3000, // Example: Replace with actual paths to your SSL certificate and key // key: path.join(process.cwd(), 'ssl', 'server.key'), // cert: path.join(process.cwd(), 'ssl', 'server.crt'), key: process.env.SSL_KEY_PATH ?? 'path/to/server.key', // Placeholder cert: process.env.SSL_CERT_PATH ?? 'path/to/server.crt' // Placeholder } }, auth: { enabled: true, users: { admin: 'password123' } }, logger: { enabled: true, path: 'access.log', type: 'combined', // Standard Apache combined log format rotation: { interval: '1d', // Rotate daily maxFiles: 10 // Keep a maximum of 10 rotated log files } } }; const server = new NodeStaticAuth(config); console.log(`Server running on HTTPS at https://localhost:${config.server.port} and HTTP listener on http://localhost:${config.server.ssl.httpListener}`);
Debug
Known issues
breakingThe package is abandoned and has not been updated in over 8 years. It is built on outdated Node.js versions (engines >= 0.10.0) and dependencies, making it insecure and incompatible with modern Node.js environments (>=16).
fix
Migrate to a actively maintained static file server solution like `serve-static`, `express.static`, or `sirv` combined with modern authentication and logging middleware.
affects: >=1.0.0
gotchaUsing custom error pages (401, 404, 500) is not supported when HTTP/2 is enabled. The server will fall back to less aesthetically pleasing default pages.
fix
If custom error pages are critical, ensure `server.http2` is set to `false` in the configuration.
affects: >=1.0.0
gotchaThe HTTP/2 support in this package is noted as 'experimental' and might contain bugs or compatibility issues, particularly with other bundled modules.
fix
Avoid using the HTTP/2 feature. If HTTP/2 is required, use a modern, actively maintained server framework that provides robust HTTP/2 support.
affects: >=1.0.0
breakingBasic Authentication, while provided, is generally insecure when used without HTTPS due to credentials being transmitted in plain text. Relying on this older, abandoned package for security-sensitive applications is extremely risky.
fix
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.
affects: >=1.0.0
gotchaThe package is CommonJS-only. Attempting to use `import` syntax will result in errors in an ESM context.
fix
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.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: require is not a function
Attempting to use `require()` in an ECMAScript Module (ESM) context.
fix
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.
Error: Cannot find module 'node-static-auth'
The package has not been installed or the path is incorrect.
fix
Run `npm install node-static-auth` in your project directory.
ERR_OSSL_EVP_UNSUPPORTED
Modern Node.js versions (e.g., Node.js 17+) have stricter OpenSSL policies that may reject older or insecure cryptographic algorithms used by outdated dependencies (like those potentially bundled here for SSL).
fix
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.
Upgrade
Version history
1.0.6latest on npm
Audit
Dependencies
node-staticrequiredCore dependency for serving static files.
basic-authrequiredProvides Basic authentication parsing and handling.
morganrequiredUsed for HTTP request logging capabilities.
rotating-file-streamrequiredEnables log file rotation for the access logger.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
2
Resources
node-static-auth — npm install node-static-auth · libregistry