【问题标题】:angular ionic - jwt token header post errorangular ionic - jwt 令牌标头发布错误
【发布时间】:2018-12-10 02:48:54
【问题描述】:

ionic v3 中,我使用以下代码通过 jwt 插件与 wordpress api 用户交流

我使用波纹管代码进行令牌验证,但它不起作用,在其他情况下,当我在 postman 中测试或通过此标头验证在线请求工具时,我认为它与服务器端无关:

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

错误Error Image

登录我使用下面的代码,它工作正常 (由 '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,这是你的问题的原因

标签: angular header ionic3 jwt wordpress-rest-api


【解决方案1】:

在后端设置 CORS 并指定标头

【讨论】:

    猜你喜欢
    • 2020-12-17
    • 2021-04-12
    • 1970-01-01
    • 2021-11-04
    • 1970-01-01
    • 1970-01-01
    • 2018-03-16
    • 2017-09-27
    • 2015-09-27
    相关资源
    最近更新 更多