Miss any of our Open RFC calls?Watch the recordings here! »

is-https

2.0.2 • Public • Published

is-https

Check if the given request is HTTPS

npm npm (scoped with tag)

Usage

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

Behaviour

isHTTPS function tries to use 2 different methods for HTTPS detection:

  • Test if x-forwarded-proto header contains https
    • Can be disabled by setting trustProxy argument to false
  • Test if req.connection.encrypted is true

Returns 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.

Related

License

MIT

Keywords

none

Install

npm i is-https

DownloadsWeekly Downloads

92,239

Version

2.0.2

License

MIT

Unpacked Size

5.41 kB

Total Files

8

Last publish

Collaborators

  • avatar