angular - angular ionic - jwt 令牌标头发布错误
问题描述
在ionic v3中,我使用以下代码通过jwt插件与wordpress api用户进行通信
我使用波纹管代码进行令牌验证,但它不起作用,在其他情况下,当我在邮递员或在线请求工具中测试时,此标头验证有效,所以我认为它与服务器端无关:
validateAuthToken(token){
return this.http.post(this.API_USER_VALID, {} , {headers: {'Content-Type': 'application/x-www-form-urlencoded','Authorization': 'Bearer ' + token}})
.subscribe((validdata)=>{
console.log(validdata);
});
}
错误: 错误图像
对于登录,我使用下面的代码,它工作正常(通过'Content-Type': 'application/json'标头不起作用,但使用'Content-Type': 'application/x-www-form-urlencoded' 工作):
doLogin(username,password){
return this.http.post(this.API_LOGIN,"username=" + username +
"&password=" + password,{headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
.subscribe((ddaa)=>{
console.log(ddaa);
});
}
我卡住了:(,如果有向导请告诉我
解决方案
在后端设置 CORS 并指定标头
推荐阅读
- visual-studio - 当我构建我的项目时,需要花费大量时间来编译
- python - 对行之间的某些值求和
- python - 使用 Pandas 在巨大的 CSV 中解析带有嵌套值的 JSON 列
- javascript - 如何传递一个跨度值 VUE
- android - 如何在 Nougat 中为 ACTION_VIEW 使用内容 URI?
- xamarin.forms - Xamarin.Forms 中用于 .Net Standard 2.0 的 ModernHttpClient
- ssl - 如何在kong中为API配置ssl
- bigcommerce - 如何在模板中获取 base_url
- javascript - 从后端强制登录 401 后做出反应
- reactjs - 在我的 React 应用程序中实现并添加自定义 polyfill