nuxt-community / auth-module

Zero-boilerplate authentication support for Nuxt 2
https://auth.nuxtjs.org
MIT License
1.93k stars 924 forks source link

Options not working in cookie strategy #1854

Open sadeghi-aa opened 1 year ago

sadeghi-aa commented 1 year ago

Hi. This is my auth module configuration in my NuxtJS 2, SSR project. The issue is that none of the options I've set in the options are actually being set; that is, the cookie is created with Expires attribute having the value of Session and so it results in the first page load being redirected to the login page. I also want other attributes like secure and httpOnly for security. Am I doing something wrong?

  auth: {
    redirect: {
      login: '/login,
      logout: '/',
      home: '/',
      callback: false,
    },
    rewriteRedirects: true,
    resetOnError: false,
    fullPathRedirect: true,
    strategies: {
      local: false,
      cookie: {
        token: {
          property: 'data.token',
          required: true,
        },
        options: {
          expires: 7,
          path: '*',
          httpOnly: true,
          secure: true,
        },
        endpoints: {
          login: { url: '/login/', method: 'post' },
          logout: { url: '/logout/', method: 'post' },
          user: false,
        },
        user: {
          property: false,
          autoFetch: true,
        },
      },
    },
    plugins: [
      '~/plugins/auth.js',
      '~/plugins/axios',
    ],
  },