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
muslnode 18–226 runs
build_error
glibcnode 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');
Errors
Common errors & fixes
TypeError: Cannot read property 'setHeader' of undefined
Calling the middleware without app.use(header()) but directly header() without options.
fixUse 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).
fixUse a framework-compatible middleware.
Audit
Dependencies
No dependency data recorded yet.