【问题标题】:Nuxt auth doesn't set user from the WordPress APINuxt auth 没有从 WordPress API 设置用户
【发布时间】:2021-02-07 06:50:21
【问题描述】:

我成功从 WordPress REST API 获取数据

data from the server

auth: {
    strategies: {
        local: {
            endpoints: {
                login: { url: 'http://localhost/wordpress/wp-json/jwt-auth/v1/token', method: 'post', propertyName: 'token' },
                user: {url: 'http://localhost/wordpress/wp-json/wp/v2/users/me/', method: 'post', propertyName: false  }, 
                tokenRequired: true,
                tokenType: 'Bearer',
                globalToken: true,
            }
        }
    },
}

但在索引页面视图中,isLogged 始终为 false。

computed: {
    isLogged() {
        return this.$auth.loggedIn;
    }
},

在 nuxt.config.js 中目标设置为 'static'。

我不知道问题出在哪里以及如何解决。

【问题讨论】:

    标签: wordpress api authentication nuxt.js


    【解决方案1】:

    我发现了问题。我安装了错误的模块。如果有人遇到同样的问题,请确保安装“@nuxtjs/auth”

    【讨论】:

      猜你喜欢
      • 2019-03-05
      • 2019-09-08
      • 2021-04-12
      • 2021-09-11
      • 1970-01-01
      • 2021-10-24
      • 2020-05-13
      • 2019-05-02
      • 1970-01-01
      相关资源
      最近更新 更多