debug-http is a minimalist Node.js utility designed to intercept and log all outgoing HTTP and HTTPS requests made within an application. It achieves this by patching Node.js's built-in `http` and `https` modules to provide visibility into request details like URL, method, and headers. The package is currently at version 1.1.0 and has not seen updates in nearly a decade, indicating it is no longer actively maintained. Its primary function is a simple, global request handler that outputs request information to the console by default, though it allows for a custom handler function. Due to its age, it exclusively supports CommonJS module loading and does not officially support modern JavaScript features like ESM or TypeScript. Alternatives like `debug` or `request-debug` offer more robust and actively maintained debugging capabilities, especially for specific HTTP client libraries or more granular control over debug output.
npm install debug-httpVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to enable global HTTP/HTTPS request debugging and then make a simple HTTP and HTTPS GET request, logging their status. It also shows a commented-out custom handler.
Thoroughly test your application when using global patching modules. Consider alternatives like `request-debug` for specific HTTP client libraries, or the `debug` package for application-level logging that doesn't modify core modules.
Evaluate modern alternatives like `debug` for general-purpose debugging or specific debugging middleware/tools for your HTTP client (e.g., `axios-debug-log` for Axios). If using it, pin the exact version and consider forking if critical updates are needed.
Ensure your project is configured for CommonJS, or use dynamic `import()` for ESM projects: `const debugHttp = await import('debug-http'); debugHttp.default();` (though this package exports directly, so `debugHttp()` after dynamic import is likely correct).Correct the CommonJS import to `const debugHttp = require('debug-http');` and then call `debugHttp();`.If your project is ESM, either switch back to CommonJS, configure Node.js to handle CJS in ESM (e.g., `"type": "commonjs"` in `package.json`), or use a dynamic import: `const debugHttpModule = await import('debug-http'); debugHttpModule.default();` (though for `debug-http`, it's `debugHttpModule()`).No dependency data recorded yet.