
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
express-enforce-https
Advanced tools
Customisable Express middleware to enforce HTTPS on requests.
Customisable Express middleware to enforce HTTPS on requests.
This is a really simple piece of middleware. When it detects that a request is using an insecure connection, it sends a response with a status code and message of your choice. You can also customise the handler function for insecure connections to tune express-enforce-https to your needs.
The main middleware function takes an options object. More on configuration in the Option reference section.
const enforceHttps = require('express-enforce-https')
const options = {
statusCode: 403
message: 'Please switch to a HTTPS connection!'
}
app.use(enforceHttps(options))
The HTTP status code to send when a request is insecure. Defaults to 403.
The message to send in response to an insecure request. Can be a string, object or anything supported by Express' res.send(). Defaults to 'Insecure connection detected, please switch to HTTPS.'.
The function to execute when an insecure connection is detected. This function has access to the req, res and next properties from Express, so you can change this any way you like.
Default:
(req, res, next) => {
res.status(options.statusCode).send(options.message)
}
Note: You lose access to the options object when overriding the handler function.
FAQs
Customisable Express middleware to enforce HTTPS on requests.
We found that express-enforce-https demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.