nuxt-community / auth-module

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

token.global is not working when module fetches user data #1776

Closed ybhwang closed 2 years ago

ybhwang commented 2 years ago

Version

module: 5.0.0-1648802546.c9880dc nuxt: ^2.15.8

Nuxt configuration

mode:

Nuxt configuration

  auth: {
    strategies: {
      local: {
        token: {
          property: 'accessToken',
          global: true
          // required: true,
          // type: 'bearer'
        },
        user: {
          property: 'user',
          autoFetch: true
        },
        endpoints: {
          login: { url: '/login', method: 'post' },
          logout: { url: '/logout', method: 'post' },
          user: { url: '/user', method: 'get' }
        }
      }
    }
  }

Reproduction

:warning: without a minimal reproduction we won't be able to look into your issue

Helpful Links:

What is expected?

Authorization should be included to Axios Headers when I got user data by endpoints.user

What is actually happening?

Backend Server can't find Authorization in Http Request, so auth module cannot process login

Steps to reproduce

  1. Set token.global: true
  2. Login with loginWith()
  3. Backend server throws Error (It caused by 'Cannot find Authorization in Header')

Additional information

Checklist

Steps to reproduce

Please check Reproduction Section.

What is expected?

Skip. Please check Reproduction Section.

What is actually happening?

Skip. Please check Reproduction Section.

Performance analysis?

Skip.

ybhwang commented 2 years ago

In addition, global is not working with any axios functions

Note(official): This determines if the authentication token is automatically included in all custom axios requests.

ybhwang commented 2 years ago

I found the problem in Backend Server. It causes with SpringBoot's Intercepter. (Request method changed to Options - preflight)