强制我的 heroku 应用程序使用 SSL (https) [英] Force my heroku app to use SSL (https)

查看:31
本文介绍了强制我的 heroku 应用程序使用 SSL (https)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Heroku 上成功运行的节点应用程序.我购买了一个 Expedited SSL 证书,一切正常.我转到 https... 并获得一个完整的绿色条",证明该网站是通过 https 提供服务的

I have a node app running successfully on Heroku. I have purchased an Expedited SSL certificate and it all works fine. I go to https... and get a full 'green bar' proving the site is being served over https

但是,非 SSL 标准 http 仍然可用.如何强制应用通过 https 提供服务?谢谢

However, the non-SSL standard http is still available too. How can I force the app to serve over https? Thanks

推荐答案

如果请求来自 HTTP,您需要将代码添加到 Node.js 应用程序以将请求重定向到 HTTPS 版本.

You need to add to the Node.js app the code to redirect the request to the HTTPS version if the request comes from HTTP.

根据您使用的框架或工具,这个想法很简单:

Depending on the framework or the tools you use, the idea is simple:

  • 检查请求方案
  • 如果是 http,则重定向到 https,传递相同的请求 uri 和查询

这篇关于强制我的 heroku 应用程序使用 SSL (https)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆