Denoder / nuxt-module-alternatives

Alternative modules to use while waiting for Nuxt 3 Compatibility
MIT License
144 stars 14 forks source link

Redirects do no longer work as expected #102

Closed ahoiroman closed 2 years ago

ahoiroman commented 2 years ago

Environment

- Operating System: `Darwin`
- Node Version:     `v18.9.0`
- Nuxt Version:     `3.0.0-rc.12`
- Nitro Version:    `0.6.0`
- Package Manager:  `npm@8.19.1`
- Builder:          `vite`
- User Config:      `experimental`, `build`, `buildModules`, `modules`, `publicRuntimeConfig`, `privateRuntimeConfig`, `globalName`, `app`, `intlify`, `http`, `proxy`, `auth`, `tailwindcss`, `googleFonts`, `content`
- Runtime Modules:  `@nuxtjs-alt/auth@2.0.20`, `@nuxtjs-alt/http@1.3.18`, `@nuxtjs-alt/proxy@1.3.5`, `@nuxt/content@2.2.0`, `@nuxtjs/tailwindcss@5.3.5`, `@nuxtjs/google-fonts@3.0.0-0`, `@intlify/nuxt3@0.2.4`, `@pinia/nuxt@0.4.3`
- Build Modules:    `@intlify/nuxt3@0.2.4`

Reproduction

-

Describe the bug

I recently upgraded to nuxt3-rc12 - I am not sure if it's related to this upgrade.

If I create a new user and login the user like this:

const {
        data: result,
        error
    } = await useAsyncApi({
        path: `/signup`, opts: {
            method: 'POST',
            body: form.value
        }
    });

    $auth.fetchUser(); // no redirect required, as the $auth middleware does this for us.
});

The user was being redirected to the route I defined in the global config:

    auth: {
        globalMiddleware: true,
        redirect: {
            home: '/dashboard',
            logout: '/',
            login: '/auth/signin',
            callback: '/backend/login',
        },
        strategies: {
            // @ts-ignore
            api: {
                provider: 'laravel/sanctum',
                url: process.env.NUXT_PUBLIC_APP_URL,
                cookie: {
                    server: true,
                    name: 'XSRF-TOKEN',
                },
                // ...
                user: {
                    property: {
                        client: false,
                        server: false
                    },
                    autoFetch: true
                }
            },
        }
    },

But unfortunately this does no longer work. I have to navigate manually like this now:

const {
        data: result,
        error
    } = await useAsyncApi({
        path: `/signup`, opts: {
            method: 'POST',
            body: form.value
        }
    });

    $auth.fetchUser(); // no redirect required, as the $auth middleware does this for us.
    navigateTo('/dashboard');
});

Additional context

No response

Logs

No response

ahoiroman commented 2 years ago

Update: This worked fine using "@nuxtjs-alt/auth": "2.0.19" .

For now I pinned that version, which fixes this issue. But 2.0.20 does not work for me.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.