android - Nativescript 不使用角度服务正确发送标头
问题描述
当我向我部署的 nodejs 网络服务器发送一个正常的 get 请求时,它告诉我没有在标头中发送 cookie,而我已经将它写在我的 api 服务的标头中
我的服务
constructor(private http: HttpClient, private global: Global) { }
verifAuth() {
return new Promise((resolve, reject) => {
this.http.get(`${this.global.url}verif`, this.global.header)
.toPromise()
.then(res => { resolve(res); })
.catch(err => { reject(err); console.log('err', err) });
});
我声明的默认标题
@Injectable({
providedIn: 'root'
})
export class Global {
url: String; header;
constructor() {
this.url = "https://fmm.etudiant.xyz/";
this.header = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'cookies': `xt=${appSetting.getString('xt')}`,
}),
withCredentials: true
};
}
}
当我调试请求时,我发现了这个
我希望必须解析令牌并获得用户的结果,但后端服务器告诉它没有 cookie,而它与其他网站一起工作正常
解决方案
尚不支持在 Http 请求中发送 Cookie,Github 上有一个开放的功能请求。
推荐阅读
- bash - 如何将环境变量从字符串传递到 bash 命令
- firebase - 意外删除 Firebase 数据
- sql-server - 在 SQL Server 存储过程中将参数设置为“可选”
- tensorflow - 无法在 Ubuntu 16.04 中配置 tensorflow 以使用 GPU 加速
- arrays - 如何返回提供的数组中包含单个项目的所有项目的数组
- php - 限制 jpg 和 pdf 上传的文件大小
- reactjs - 为什么 req.query 总是空的?
- html - 为什么悬停在 flex 或 grid 中不起作用?
- python - 无法在 Docker alpine 映像中安装 Psycopg2
- kotlin - 微调器和切换按钮的中性状态