nuxt-community / auth-module

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

"TypeError: _schemes_index_js__WEBPACK_IMPORTED_MODULE_7___default.a is not a constructor" when setting "cookie" auth strategy #1689

Open franck-grenier opened 2 years ago

franck-grenier commented 2 years ago

Hello, I'm trying to change the auth strategy of my Nuxt (2.14.11) app from local to cookie and I'm getting this error :

TypeError: _schemes_index_js__WEBPACK_IMPORTED_MODULE_7___default.a is not a constructor

(I'm using @nuxtjs/auth 4.9.1.)

I guess my TS compilation is faulty here but I can't understand why with cookie and why not with local.

Thanks for your help !

ebi-yade commented 2 years ago

I'm facing the same issue.

justindasilva commented 2 years ago

I'm also seeing this issue.

franck-grenier commented 2 years ago

Hello, I fixed this problem with the below configuration :

{
    auth: {
        cookie: {
            options: {
                expires: 365,
                secure: process.env.APP_ENV !== 'local',
            },
        },
        strategies: {
            local: {
                endpoints: {
                    login: {
                        url: 'auth/login',
                        method: 'post',
                        propertyName: 'token',
                    },
                    user: {
                        url: 'users/me',
                        method: 'get',
                        propertyName: null,
                    },
                    logout: false,
                },
            },
        },
        plugins: [
            '~/plugins/updateLoggedInUser.js',
        ],
    },
}

My goal was to change the parameters of the local strategy cookie.

Hope it will help

kostandy commented 2 years ago

Hello, I fixed this problem with the below configuration :

{
    auth: {
        cookie: {
            options: {
                expires: 365,
                secure: process.env.APP_ENV !== 'local',
            },
        },
        strategies: {
            local: {
                endpoints: {
                    login: {
                        url: 'auth/login',
                        method: 'post',
                        propertyName: 'token',
                    },
                    user: {
                        url: 'users/me',
                        method: 'get',
                        propertyName: null,
                    },
                    logout: false,
                },
            },
        },
        plugins: [
            '~/plugins/updateLoggedInUser.js',
        ],
    },
}

My goal was to change the local strategy cookie params.

Hope it will help

Also faced with the same issue. Configuration above solved my problem. Thanks!

MatthD commented 2 years ago

We have the same issue on Nuxt2 with vue 2.7 !