本文介绍了如何使用Falcor从客户端发送身份验证令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我在客户端上有以下代码:

Now I have following code on the client:

var model = new falcor.Model({
    source: new falcor.HttpDataSource('/model.json')
});

我完全了解如何使用falcor-router类在服务器端处理令牌.我的问题是如何随浏览器的每个请求发送令牌(如何更改上面的代码)?我只是找不到任何信息.一旦falcor对开发人员隐藏了网络,我希望它为HTTP请求提供一些选择.

I completely understand how to handle tokens on the server side using falcor-router class. My question is how to send tokens with each request from the browser (how to change code above)? I just couldn't find any information. As soon as falcor hides network from developer I expect it to have some options for HTTP requests.

我真的很感谢答案.

推荐答案

gdi2290

var model = new falcor.Model({
    source: new falcor.HttpDataSource( '/model.json', {
        // Options here
        headers: {
            // Any headers here
            'Authorization': `bearer ' + token` // JWT
        },
        withCredentials: true, // Cookies
        crossDomain: true // CORS
    })
});

这篇关于如何使用Falcor从客户端发送身份验证令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 10:51