Module for hijacking and rewriting HTTP response bodies in middleware stacks. Version 5.0.0 requires Node >=8.0.0. It is a spiritual successor to express-hijackresponse, with no direct coupling to Express and support for streams2. Main use cases are content filtering, inline script injection, and transpiler/preprocessor middleware (e.g., express-processimage, express-autoprefixer). It provides fine-grained control over response interception via a promise-based API.
npm install hijackresponseNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates hijacking a response, conditionally skipping HTML, and piping through a transform stream.
Always call readable.pipe(writable) (possibly through a transform) in the hijack callback, or use destroyAndRestore() to restore original behavior.
Call res.removeHeader('Content-Length') before piping through a transform stream.Pass next as the second argument to hijackResponse, or await the promise before calling next.
Ensure you set headers (via setHeader) only after the hijack promise resolves, and avoid direct res.write/end – always use the writable stream.
Do not write to res directly after hijacking; write to the writable stream only.
No dependency data recorded yet.