is-https
Check if the given request is HTTPS
Last updated a month ago by pi0 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install is-https 
SYNC missed versions from official npm registry.

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

Current Tags

  • 3.0.2                                ...           latest (a month ago)

7 Versions

  • 3.0.2                                ...           a month ago
  • 3.0.1                                ...           a month ago
  • 3.0.0                                ...           a month ago
  • 2.0.2                                ...           8 months ago
  • 2.0.1                                ...           8 months ago
  • 2.0.0                                ...           8 months ago
  • 1.0.0                                ...           3 years ago

Copyright 2014 - 2016 © taobao.org |