Registry / http-networking / connect-header

connect-header

JSON →
library0.0.5jsnpmunverified

General header middleware for Connect/Express that allows setting arbitrary HTTP response headers via middleware configuration. Version 0.0.5 is the last release; no recent activity (last updated ~10 years ago). Extremely lightweight (no dependencies). Simpler than helmet or custom middleware for basic header setting, but unmaintained and not compatible with modern Express (>=4.x) or Koa.

npm install connect-header
INSTALL
IMPORT
SIG · CONNECT-HEADER
C
connect-header
http-networkingjavascriptv0.0.5
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

connect-header
✓ const header = require('connect-header')
✗ import header from 'connect-header'
This package does not export ES modules; it uses CommonJS.
configured middleware
✓ app.use(header({ 'X-Custom': 'value' }))
✗ app.use(header) // calling without options
The middleware is a function that takes an options object; calling it without options will throw.
Express usage
✓ const express = require('express'); const header = require('connect-header'); const app = express(); app.use(header({ 'X-Frame-Options': 'DENY' }))
✗ app.use(header({ 'X-Frame-Options': 'DENY' })) // without requiring express properly
Works with Express 3.x; may not be compatible with Express 4+ routing changes.

Shows how to set multiple HTTP security headers using connect-header middleware in a vanilla Connect app.

const http = require('http'); const connect = require('connect'); const header = require('connect-header'); const app = connect(); app.use(header({ 'X-Frame-Options': 'DENY', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains' })); app.use((req, res) => { res.end('Hello World!'); }); http.createServer(app).listen(3000); console.log('Server running on port 3000');
Debug
Known issues
gotchaMust pass an options object; calling the middleware without arguments will throw an error.
fix
Always call header({ ... }) with an object.
affects: all
deprecatedPackage is essentially unmaintained; no updates since 2013.
fix
Consider using helmet or write your own middleware.
affects: all
gotchaCompatibility issues with Express 4.x due to changes in middleware signature.
fix
Use with Express 3.x or migrate to helmet.
affects: all
gotchaThe middleware sets headers for every request; cannot conditionally set headers based on route or request properties.
fix
Use a custom middleware with conditions if needed.
affects: all
Errors
Common errors & fixes
TypeError: Cannot read property 'setHeader' of undefined
Calling the middleware without app.use(header()) but directly header() without options.
fix
Use app.use(header({ 'X-Custom': 'value' }))
TypeError: Object #<Object> has no method 'set'
Using the middleware with a framework that does not have a 'set' method on the response object (e.g., Koa or modern Express).
fix
Use a framework-compatible middleware.
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
connect-header — npm install connect-header · libregistry