nuxt-community / auth-module

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

Redirect to /undefined/ after successful login #1806

Open abieleck opened 1 year ago

abieleck commented 1 year ago

Hi,

I'm struggling with getting right the redirect after login. Currently the redirect path starts with /undefined/. I found in the code where this undefined comes from:

https://github.com/nuxt-community/auth-module/blob/dfbbb540c5e6c1f0bff0b356c46f50d48ee3f9a5/src/core/auth.ts#L446

In my case this.ctx.base is indeed undefined.

Kind regards, Artur

abieleck commented 1 year ago

The workaround seems to be setting the base property to empty string when creating the router:

new Router({
    mode: 'history', // or other
    routes: [ /* your routes here */],
    scrollBehavior(to, from, savedPosition) {
        /* return your scroll behavior */
    },
    base: '',
})

Anyway, I guess null base should also be correctly handled, as it is defined as nullable in TypeScript source.