Can't fetch user right after login, but refresh works @nuxt-auth

Lynx

Login is successful, but can't fetch user infos until i refresh the page.

// Login Component
  try {
    await this.$auth.loginWith("mg_login", {
      data: this.user,
    });
  } catch (e) {
    this.$toast.error("Error!", { duration: 1500 });
  }


// Nuxt config
    auth: {
    strategies: {
        'mg_login': {
            provider: 'laravel/sanctum',
            url: `http://localhost`,
            maxAge: 60 * 60 * 120,
            endpoints: {
                user: {
                    url: '/api/user',
                    method: 'GET',
                    propertyName: false
                },
                login: {
                    url: '/login',
                    method: 'POST'
                },
                csrf: {
                    url: '/sanctum/csrf-cookie',
                    method: 'GET'
                },
            },
            cookie: {
                name: 'mg_session',
                options: {
                    path: '/',
                    sameSite: 'none',
                    maxAge: 60 * 60 * 120,
                }
            },
        },
    },
    redirect: {
        home: '/'
    },
},

After that I tried setting user infos manually by using $auth.setUser(user) or $auth.setUser({user}) in login component, also property/propertyName : ' '/undefined/false options in nuxt.config, still no hope.

Basically, can't fetch user(or set user) if I don't refresh the page. http://localhost/api/user response right below:

/api/user response (image)

What i am missing right now?

Lynx

Deleting cookie options from nuxt config solved everything. Seems like laravel and nuxt putting cookies in same name and causing a collision.

Still I can't understand why auth couldn't fetch user right after login, but needs to refresh the page.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Can't login to MediaWiki right after installation

Forced page transition after login with nuxt/auth

django - Can't login after creating user

Can't route after user login in rails

Auth guard redirect to login after refresh

Nuxt and $auth in Fetch()

Swift - Login with FireBase - Can't retrieve user data after login

Auth::user() not found after login laravel 6

Fetch only works on refresh

Nuxt auth with a guest and auth middleware redirects an authenticated user on refresh to the wrong page

can't retrieve user data after the login check

Can't keep all data of user in session after login at codeigniter

Laravel: can't login user after revoke token in api testst

Why user is not authenticated after google authorization in nuxt-auth-next?

How to get user info after a successful authentication with nuxt-auth

Firebase auth - Login and then redirect to app - How to fetch user

user folder disappear, Can't login as root and only guest user works

In Django, after a login how can I detect which auth backend authenticated the user?

Laravel 5.5 - How can I add a custom value to Auth::user() after successfully login

Can't refresh data when user login using Vue.js

Nuxt auth module fails to login

Firebase Auth Import SHA256 Hash: Can't login with password after import

Can't login with google.auth Python

Can't login to new user

Can't login to Root User

Can't get next user command right after "consoleHandler" function get Ctrl-C from user

Django, can't transmit user login status among pages after register and login

A specific user can't login (after connecting TV), can't figure out why

Can't get nVidia drivers working with 16.04, logs out right after login