Home > Net >  which to prefer http vs https in nodejs
which to prefer http vs https in nodejs

Time:10-23

Recently i learned about https module in nodejs,
Like How to use it and generating certificate and key for it.
But there is also http module which most of the tutor teaches at beginning.

But the main question is,
when i create back-end server with http module.
and hosted on website like heroku after deploying we get by default https protocol for our website and its secure.
and even same for using https module

so what's the difference/advantage we get by using http/https module on one over another protocol?
does it make difference?

and which module to prefer while writing server code?

CodePudding user response:

When you are running in a hosting environment like heroku that puts you behind a proxy and that proxy handles the https to the outside world for you, then that's all you need. There is no need to use https on your server directly between you and the proxy as it already has https to the outside world via the proxy and you don't need https between your server and the proxy as that's local to the secure network of the hosting facility.

If you are not running behind such a proxy, then you will want your own server to be https.

CodePudding user response:

In order to ensure secure communication with users of your Express.js applications, you can make all traffic to use HTTPS, by forcing a redirect from HTTP.

  • Related