$ cnpm install is-https
Check if the given request is HTTPS
Install package:
yarn add is-https
# or
npm install is-https
const isHTTPS = require('is-https')
// or
import isHTTPS from 'is-https'
function isHTTPS(req: IncomingMessage, trustProxy: Boolean = true): Boolean | undefined
isHTTPS function tries to use 2 different methods for HTTPS detection:
x-forwarded-proto header contains https
trustProxy argument to falsereq.connection.encrypted is trueReturns either true or false based on checks or undefined if no check was reliable.
TIP: If you want to redirect users from http to https, it is better using isHTTPS(req) === false to avoid redirect loops.
MIT
Copyright 2013 - present © cnpmjs.org | Home |