axios-module icon indicating copy to clipboard operation
axios-module copied to clipboard

Authorization header is not being set with Auth Module cookie strategy

Open sadeghi-aa opened this issue 9 months ago • 0 comments

Hi. I have a NuxtJS project that is running on SSR mode and the auth module configuration is like this:

  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',
    ],
  },

The problem is that Axios doesn't set the Authorization header in the requests after login. I worked around this issue by using the setToken helper in the client side, but this doesn't help with the requests made on the server side. How can I solve this issue?

I didn't have this issue with local strategy. I also tried setting credentials: true in the axios configuration but it didn't help.

sadeghi-aa avatar Oct 01 '23 06:10 sadeghi-aa