【发布时间】:2019-08-18 14:12:52
【问题描述】:
将请求标头设置为 Falcor HttpDataSource 的记录方法对我来说并不适用。可能我只是在某个地方犯了一个愚蠢的错误,因为 Falcor 对我来说是全新的概念。
文档: https://github.com/Netflix/falcor-http-datasource#readme
这些我已经检查过了: How to send auth tokens from the client with Falcor https://github.com/ekosz/redux-falcor/issues/7
我还尝试从 onBeforeRequest 设置请求标头,但这并没有什么不同。我发送到服务器的标头将位于“访问控制请求标头”下。我的意思是只有标题名称可见,但值无处可见或访问。
客户端:
const model = new falcor.Model({
source: new falcor.HttpDataSource('http://localhost:3001/api/users/model.json', {
headers: {
'x-auth-token': "secret"
}
})
});
model.get(["gamesById", ['5c4cb04fb7ccdd14a81cfe89'], ['name']])
.then(function (response) {
console.log(response);
});
当我从服务器端控制台记录标头时,我得到了这个:
{ host: 'localhost:3001',
connection: 'keep-alive',
'access-control-request-method': 'GET',
origin: 'http://localhost:63342',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko
) Chrome/73.0.3683.86 Safari/537.36',
'access-control-request-headers': 'x-auth-token',
accept: '*/*',
referer: 'http://localhost:63342/gamebase-backend/index.html?_ijt=mssfaptvvjpofa44aqm1n9dt1v',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'fi-FI,fi;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6' }
当我登录req.header('x-auth-token') 时,我得到undefined,但是当我登录这个req.header('access-control-request-headers'); 时,我得到x-auth-token 作为结果。
【问题讨论】:
标签: javascript node.js falcor falcor-router