根据标题,我有一个 Node.js 应用程序,我希望能够检测请求是通过 HTTPS 还是 HTTP 发出。到目前为止我的重定向看起来像这样:
// Ensure the page is secure, or that we are running a development build
if (req.headers['x-forwarded-proto'] === 'https' || process.env.NODE_ENV === 'development') {
res.render('index');
} else {
winston.info('Request for login page made over HTTP, redirecting to HTTPS');
res.redirect('https://' + req.host);
}
这在 Nodejitsu 上运行良好,但重定向的 HTTPS 请求在 Azure 上没有设置“x-forwarded-proto”标头。
我认为我的评论是正确的:
X-ARR-SSL
似乎是要检查的标题。
// Ensure the page is secure, or that we are running a development build
if (req.headers['x-forwarded-proto'] === 'https' || req.headers['x-arr-ssl'] || process.env.NODE_ENV === 'development') {
res.render('index');
} else {
winston.info('Request for login page made over HTTP, redirecting to HTTPS');
res.redirect('https://' + req.host);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)