JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 235328
  • Score
    100M100P100Q168007F
  • License MIT

Check if the given request is HTTPS

Package Exports

  • is-https

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (is-https) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

is-https

Check if the given request is HTTPS

npm npm (scoped with tag)

Usage

Install package:

yarn add is-https
# or
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

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

  • Test if x-forwarded-proto header contains https
  • Can be disabled by setting truestProxy 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.

License

MIT