| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/is-https/ |
Upload File : |
# is-https
> Check if the given request is HTTPS
[](https://npmjs.com/package/is-https)
[](https://npmjs.com/package/is-https)
## Usage
Install package:
```bash
yarn add is-https
# or
npm install is-https
```
```js
const isHTTPS = require('is-https')
// or
import isHTTPS from 'is-https'
```
```ts
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
- [redirect-ssl](https://www.npmjs.com/package/redirect-ssl) - Connect middleware to enforce HTTPS
## License
MIT