首页 > 解决方案 > 我的 nuxt-auth 令牌配置正确,但令牌从未存储

问题描述

这是我的身份验证配置

  auth: {
    strategies: {
      local: {
        endpoints: {
          login: {
            url: "/api/auth/login",
            method: "post",
            propertyName: "token"
          },
          logout: { url: "/api/auth/Logout", method: "post" },
          user: {
            url: "/api/user/detail",
            method: "get",
            propertyName: "user"
          }
        },
        tokenRequired: true,
        tokenName: "Authorization",
        globalToken: true,
        tokenType: "bearer",
        autoFetchUser: true
      }
    }
  },

我检查了一百次。

我确实有一个令牌对象返回。

{token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6I…M2Nn0.Fu5ugLtucxa6cDlD04D5ffQYs4dIKvcqtngJ5J3b5js"}

出于某种原因,我的第二个请求不起作用。我检查了因为标题处没有令牌,我检查了听到的说:

Authorization":"bearer undefined

这就是为什么我的第二个请求不起作用,没有令牌。

标签: authenticationnuxt.js

解决方案


推荐阅读