nuxt-alt / auth

An alternative module to @nuxtjs/auth
https://nuxt-alt-auth.vercel.app/
MIT License
112 stars 20 forks source link

useAuth() gives trouble when executing loginWith() #105

Closed azmatzuberi closed 9 months ago

azmatzuberi commented 9 months ago

Environment


Nuxt Config

devtools: { enabled: false },
modules: ['@nuxt-alt/auth'],
auth: {
    globalMiddleware: true,
    enableMiddleware: true,
    redirect: {
        login: '/sign-in',
        logout: '/',
        callback: '/',
        home: '/',
    },
    strategies: {
        local: {
            scheme: 'refresh',
            token: {
                property: 'access_token',
                maxAge: 1800,
                global: true,
                type: '',
                max: 60 * 10,
                name: 'api-x-auth-token',
            },
            refreshToken: {
                property: 'refresh_token',
                data: 'refresh_token',
                maxAge: 60 * 60 * 24 * 7,
            },
            user: {
                property: 'user',
                // data: 'user'
                autoFetch: false,
            },
            endpoints: {
                login: {
                    url: `http://localhost:4500/api/users/sign-in`,
                    method: 'post',
                },
                logout: {
                    url: `http://localhost:4500/api/users/logout`,
                    method: 'post',
                },
                refresh: {
                    url: `http://localhost:4500/api/users/refresh`,
                    method: 'post',
                },
                user: {
                    url: `http://localhost:4500/api/users/user-info`,
                    method: 'get',
                },
            },
            // autoLogout: false
        },
    },
},

Reproduction

Add useAuth().loginWith() for local scheme and execute function. Screenshot 2024-01-24 at 2 08 44 PM

Describe the bug

Screenshot 2024-01-24 at 2 09 21 PM

Additional context

Tried everything from installing Pinia to adjusting order of Nuxt modules, but nothing worked.

Logs

No response

Denoder commented 9 months ago

Can you show me what the Preview and Response is putting out?

azmatzuberi commented 9 months ago

Here are the two items you asked for: Screenshot 2024-01-24 at 6 51 45 PM Screenshot 2024-01-24 at 6 51 58 PM

Denoder commented 9 months ago

This leads me to believe that anything under http://localhost:4500 wont output anything.

Denoder commented 9 months ago

are you able to provide a reproducible link for me to test this?

azmatzuberi commented 9 months ago

It was my error.

On Fri, Jan 26, 2024 at 12:58 AM Tera @.***> wrote:

are you able to provide a reproducible link for me to test this?

— Reply to this email directly, view it on GitHub https://github.com/nuxt-alt/auth/issues/105#issuecomment-1911527886, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSEEZVU2A3QHANC2JFMBTDYQNAZHAVCNFSM6AAAAABCJI7MNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJRGUZDOOBYGY . You are receiving this because you authored the thread.Message ID: @.***>