Socket
Socket
Sign inDemoInstall

is-https

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-https

Check if the given request is HTTPS


Version published
Weekly downloads
292K
increased by0.96%
Maintainers
1
Install size
5.11 kB
Created
Weekly downloads
 

Changelog

Source

4.0.0 (2021-05-17)

⚠ BREAKING CHANGES

  • pkg: add exports field

Features

Readme

Source

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.

License

MIT

FAQs

Last updated on 17 May 2021

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc