快速请求对象不正确报告https

我试图自动redirect我的网站的用户到https,但为了这样做,我需要知道他们是否已经通过https 访问 ,否则我会进入一个无限的redirect循环。

从search,我试着看这些值

console.log('!!!!!!!!!ROUTING TO REDUX!!!!!!!!', request.secure, request.protocol, request.get('X-Forwarded-Protocol')); 

但我看到这个logging

2017-06-23T07:20:10.996750 + 00:00 app [web.1]:!!!!!!!!! ROUTING TO REDUX !!!!!!!! 错误的http undefined

2017-06-23T07:20:11.028280 + 00:00 heroku [router]:at = info method = GET path =“/”host = my-library-io.herokuapp.com request_id = 3fc84fae-02bd-443a-8265- c45def605ba1 fwd =“64.134.226.42”dyno = web.1 connect = 0ms service = 33ms status = 200 bytes = 2309 protocol = https

即使在查看https时。

网站在这里https://mylibrary.io/原来的Herokuurl在这里https://my-library-io.herokuapp.com/

这两个URL都会加载,并且在我的浏览器中显示为安全,但两者都显示为通过上面的第二个条目logging为https; 但无论我不能看任何请求对象来推测,我通过https查看。

使用request.get('X-Forwarded-Proto') ,而不是X-Forwarded-Protocol 。 正如你所看到的,它是由npm包heroku-ssl-redirect 。 这个事实上的标准HTTP头也被logging在维基百科上 。