记录的将请求标头设置为Falcor HttpDataSource的方法对我来说不可行。因为Falcor对我来说是全新的概念,所以我可能在某个地方犯了一个愚蠢的错误。文档:https : //github.com/Netflix/falcor-http-datasource#readme这些我已经签出了: 如何使用Falcor从客户端发送身份验证令牌 https://github.com/ekosz/redux-falcor/issues/7我还尝试设置onBeforeRequest的请求标头,但这没有什么区别。我发送到服务器的标头将位于“ access-control-request-headers”下。通过这种方式,我的意思是仅标题名称是可见的,但值无处可见或访问。客户端: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了结果。
1 回答

海绵宝宝撒
TA贡献1809条经验 获得超8个赞
看起来您正在使用HttpDataSourcefalcor软件包中的。尝试安装falcor-http-datasource并使用该版本。HttpDataSource与主falcor软件包捆绑在一起的版本可能是较旧的版本。
例如
import falcor from 'falcor';
import HttpDataSource from 'falcor-http-datasource';
const model = new falcor.Model({
source: new HttpDataSource('http://localhost:3001/api/users/model.json', {
headers: {
'x-auth-token': "secret"
}
})
});
添加回答
举报
0/150
提交
取消