【问题标题】:gcloud can't send custom https header datagcloud 无法发送自定义 https 标头数据
【发布时间】:2016-04-09 03:42:58
【问题描述】:
我正在使用 nodeJs 开发云应用程序,我在请求正文中发送数据,并在请求头中发送密钥。
然后我检查并验证我在标头中发送的密钥,当我在 127.0.0.1:8080 上本地运行应用程序时/我让一切运行良好。
但是,当我将应用程序部署到云时,它不起作用。
它看不到我在 https 请求中发送的元数据(变量)。
有什么办法吗??
【问题讨论】:
标签:
node.js
google-app-engine
https
http-headers
gcloud-node
【解决方案1】:
您应该能够使用拦截器来添加自定义标头
var gcloud = require('gcloud')({
projectId: 'grape-spaceship-123',
keyFilename: '/path/to/keyfile.json'
});
gcloud.interceptors.push({
request: function(requestOptions) {
requestOptions.headers = requestOptions.headers || {};
requestOptions.headers['x-secret-key'] = 'yahtzee';
return requestOptions;
}
});
【解决方案2】:
gcloud 似乎拒绝了 header key 参数中的下划线字符。