nuxtjs和scatum副本请求,没有存储的cookie

发布于 2025-01-23 14:10:10 字数 1677 浏览 2 评论 0原文

我面临一个奇怪的问题。我有一个Laravel API服务器设置和NUXTJS前端。我正在使用laravelsanctum nuxtjs中的提供商。我能够发送请求,并且身份验证和数据检索很好。但是,cookie似乎没有存储在我的本地存储中。

login.vue

<script>
export default {
  async login() {
    this.$auth.loginWith('laravelSanctum', {
      data: {
        email: '[email protected]',
        password: 'test',
      },
    })
  },
}
</script>

nuxt.config.js

axios: {
  baseURL: 'http://local.api.test/api/v1/',
  proxy: true,
  credentials: true,
},

proxy: {
  '/laravel': {
    target: 'http://local.api.test/api/v1/',
    pathRewrite: { '^/laravel': '/' },
  },
},

auth: {
  strategies: {
    laravelSanctum: {
      provider: 'laravel/sanctum',
      url: 'http://local.api.test',
      endpoints: {
        login: {
          url: '/api/v1/login/admin',
        },
        user: {
          url: '/api/v1/admin',
        },
      },
    },
  },
},

“在此处输入映像说明”

“

​“ https://i.sstatic.net/iahgf.png” rel =“ nofollow noreferrer”>

I am facing a weird problem. I have a Laravel API server setup and a Nuxtjs frontend. I am using LaravelSanctum Provider in Nuxtjs. I am able to send request and the authentication and data retrival is fine. However, the cookies doesn't seem to get stored in my local storage.

login.vue

<script>
export default {
  async login() {
    this.$auth.loginWith('laravelSanctum', {
      data: {
        email: '[email protected]',
        password: 'test',
      },
    })
  },
}
</script>

nuxt.config.js

axios: {
  baseURL: 'http://local.api.test/api/v1/',
  proxy: true,
  credentials: true,
},

proxy: {
  '/laravel': {
    target: 'http://local.api.test/api/v1/',
    pathRewrite: { '^/laravel': '/' },
  },
},

auth: {
  strategies: {
    laravelSanctum: {
      provider: 'laravel/sanctum',
      url: 'http://local.api.test',
      endpoints: {
        login: {
          url: '/api/v1/login/admin',
        },
        user: {
          url: '/api/v1/admin',
        },
      },
    },
  },
},

enter image description here

enter image description here

enter image description here

No cookies stored

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文