IE No Open Middleware
raw JSON →ienoopen is an Express-compatible middleware designed to enhance client-side security by setting the `X-Download-Options` HTTP header to `noopen`. This header, primarily relevant for Internet Explorer 8 and later, prevents users from directly opening downloaded HTML files in the browser's context, thereby mitigating certain types of HTML injection and cross-site scripting (XSS) attacks by forcing a "Save" action instead. The package is currently at version 1.1.1, with its last update over six years ago. It is considered to be in maintenance mode, as its standalone GitHub repository is archived, and its functionality has been integrated into the comprehensive `Helmet` security middleware suite, which includes `ienoopen` by default as `helmet.ieNoOpen()`. This package's narrow focus on a single, legacy IE-specific security header is its key differentiator, although its practical relevance has significantly diminished with modern browser adoption.
Common errors
error TypeError: ienoopen is not a function ↓
ienoopen() to get the middleware function: app.use(ienoopen()); error Error: Cannot find module 'ienoopen' ↓
npm install ienoopen or yarn: yarn add ienoopen. Double-check the import/require statement for typos. Warnings
deprecated The `X-Download-Options` header, which this package sets, is an unofficial header primarily implemented by Internet Explorer 8+. Modern browsers like Chrome, Firefox, and Safari do not support this header, making its security benefits largely irrelevant for contemporary web development. ↓
gotcha The standalone `ienoopen` package is no longer actively maintained, and its GitHub repository is archived. While functional, no further updates or bug fixes are expected for this standalone module. ↓
gotcha The `X-` prefix for HTTP headers (e.g., `X-Download-Options`) has been deprecated. While still understood by older systems, new headers should avoid this convention. ↓
Install
npm install ienoopen yarn add ienoopen pnpm add ienoopen Imports
- ienoopen wrong
import { ienoopen } from 'ienoopen';correctimport ienoopen from 'ienoopen'; - ienoopen
const ienoopen = require('ienoopen'); - ienoopen.d.ts
import type { RequestHandler } from 'express';
Quickstart
import express from 'express';
import ienoopen from 'ienoopen';
const app = express();
const port = 3000;
// Apply the ienoopen middleware
// This sets the 'X-Download-Options: noopen' header
app.use(ienoopen());
app.get('/', (req, res) => {
res.send('Hello World! X-Download-Options header set.');
});
app.get('/download-unsafe-html', (req, res) => {
res.setHeader('Content-Type', 'text/html');
res.setHeader('Content-Disposition', 'attachment; filename="malicious.html"');
// In older IE, without X-Download-Options: noopen, this could be opened directly.
res.send('<html><body onload="alert(\'Malicious script executed in site context!\')"><h1>Untrusted content</h1></body></html>');
});
app.listen(port, () => {
console.log(`Server listening at http://localhost:${port}`);
console.log('Check response headers for X-Download-Options: noopen on relevant routes.');
});