Categories
JavaScript Answers

How to know if a request is http or https in Node.js?

Spread the love

To know if a request is http or https in Node.js, we use the req.secure property.

For instance, we write

const isSecure = req.secure;

to check if the request is secure with the req.secure property.

If it’s true, then the request is made via https.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *