How to force SSL / https in Express.js

后端 未结 8 1750
小鲜肉
小鲜肉 2020-11-27 11:54

I am trying to create a middleware for Express.js to redirect all non-secure (port 80) traffic to the secured SSL port (443). Unfortunately there is no information in an Exp

8条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 12:51

    Since I was working on nginx, I had access to the header's x-forwarded-proto property so I could write a tiny middleware to redirect all traffic as described here: http://elias.kg/post/14971446990/force-ssl-with-express-js-on-heroku-nginx

    Edit: Updated the url

提交回复
热议问题