Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
redirect-ssl
Advanced tools
Connect/Express middleware to enforce https using is-https.
Install package:
yarn add redirect-ssl
# or
npm install redirect-ssl
Require and use redirect-ssl
. Make sure to use this middlware as the first in your middleware chain (if using express see middleware chain:
import redirectSSL from 'redirect-ssl'
// or
const redirectSSL = require('redirect-ssl')
// Add middleware
app.use(redirectSSL)
// Using custom options
app.use(redirectSSL.create({ redirectPort: 8443 }))
If you want to disable on localhost
, use the exclude option:
app.use(redirectSSL.create({
exclude: ['localhost']
}))
Only enable in production environments:
app.use(redirectSSL.create({
enabled: process.env.NODE_ENV === 'production'
}))
true
Trust and check x-forwarded-proto
header for HTTPS detection.
true
443
Redirect users to this port for HTTPS. (:443
is omitted from URL as is default for https://
schema)
req.headers.host
Redirects using this value as host, if omitted will use request host for redirects.
NOTE It should not contain schema or trailing slashes. (Example: google.com
)
true
Redirect when no SSL detection method is available too. disable this option if you encounter redirect loops.
307
Temporary RedirectStatus code when redirecting. The reason of choosing 307
for default is:
POST
TO GET
by user agents. (If you don't care, use 302
Found)308
Permanent Redirect or 301
Moved Permanently)[]
An array of routes patterns for which redirection should be disabled.
Add the redirect-ssl
to the serverMiddleware
array within in the nuxt.config.js file is the preferred usage:
import redirectSSL from 'redirect-ssl'
export default {
serverMiddleware: [
redirectSSL.create({
enabled: process.env.NODE_ENV === 'production'
}),
]
}
You will still need to install this package within your project for it work.
MIT. Made with 💖
FAQs
Connect/Express middleware to enforce https
The npm package redirect-ssl receives a total of 3,830 weekly downloads. As such, redirect-ssl popularity was classified as popular.
We found that redirect-ssl 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.