is-req-https2
v1.0.9
Published
This module returns whether a request is under https
Maintainers
Readme
is-req-https
This module returns whether a request is under https
Installation
yarn add is-req-https2Users
- Node.js
- Express
- Hapi
Usage
If one of the following test is true, the function immediately return true.
- Check if
req.connection.encryptedexist. - Check the property
req.secure. - Check the
x-forwarded-protoin headers - Check
req.server.info.protocolfor Hapi requests
Otherwise the function returns false.
Example
import isHttps from 'is-req-https2';
// for express users
app.use((req, res, next) => {
req.isSecure = isHttps(req);
next();
});