【问题标题】:How to send auth tokens from the client with Falcor如何使用 Falcor 从客户端发送身份验证令牌
【发布时间】:2015-12-13 11:16:31
【问题描述】:

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

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

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

非常感谢您的回答。

【问题讨论】:

    标签: falcor falcor-router


    【解决方案1】:

    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
        })
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-01
      • 1970-01-01
      • 2019-12-01
      • 2021-08-18
      • 2013-08-19
      • 1970-01-01
      • 2015-11-03
      • 2013-12-26
      相关资源
      最近更新 更多