【发布时间】:2015-01-28 15:36:20
【问题描述】:
我正在使用库来检查 req.secure 选项以继续没有错误。但我的应用程序也部署到heroku,我使用自定义中间件检查“x-forwarded-proto”标头并将req.secure设置为true,req.protocol设置为“https”,但实际上这些选项在之后保持不变操作。在为 req.secure 和 req.protocol 赋值后,我立即进行了调试输出,我可以看到这些选项没有被修改。它肯定会通过该代码,因为我看到了“x-forwarded-proto”==“https”案例的调试信息。在 express js 中设置此类 var 有什么限制吗?
SailsJS v0.10.5
我在 config/http.js 中的自定义中间件代码:
if (req.headers['x-forwarded-proto'] === 'https'){
req.secure = true;
req.protocol = 'https';
sails.log('Secure headers detected: secure - ', req.secure, ', protocol - ', req.protocol);
}
输出:
debug: Secure headers detected: secure - false , protocol - http
【问题讨论】:
标签: javascript node.js heroku express sails.js