我需要设置我的JSData配置,以传递基于cookie的会话身份验证以及CSRF头的信息。
发布于 2018-03-28 18:14:26
实例化HttpAdapter时,使用以下方法设置withCredentials (阅读更多)和CSRF报头(下面的示例设置X-CSRFToken报头,但这是服务器端框架特有的;在其他情况下可能是另一种情况)。
const adapter = new HttpAdapter({
...
httpConfig: {
withCredentials: true // send cookie-based session credentials
},
...
beforeHTTP: function(config, opts) {
...
config.headers || (config.headers = {});
config.headers['X-CSRFToken'] = token;
...
return HttpAdapter.prototype.beforeHTTP.call(this, config, opts);
}
})https://stackoverflow.com/questions/49541460
复制相似问题