-
-
Notifications
You must be signed in to change notification settings - Fork 189
Open
Labels
needs-reproductionAction needed: A valid reproduction of the issue needs to be addedAction needed: A valid reproduction of the issue needs to be addedprovider-authjsAn issue with the authjs providerAn issue with the authjs provider
Description
Environment
- Operating System:
Darwin - Node Version:
v20.11.0 - Nuxt Version:
3.14.159 - CLI Version:
3.15.0 - Nitro Version:
2.10.4 - Package Manager:
npm@10.2.4 - Builder:
- - User Config:
default - Runtime Modules:
@nuxt/image@1.8.1,vue-yandex-maps/nuxt,nuxt-swiper@1.2.2,@pinia/nuxt@0.5.5,nuxt-mongoose@1.0.6,@sidebase/nuxt-auth@0.9.4,@nuxt/test-utils/module@3.14.4,yandex-metrika-module-nuxt3@1.5.3,@nuxtjs/seo@2.0.0-rc.23,@nuxtjs/i18n@8.5.6 - Build Modules:
-
Reproduction
my [...].ts file
import { NuxtAuthHandler } from '#auth';
import CredentialsProvider from 'next-auth/providers/credentials';
import bcrypt from 'bcrypt'
export default NuxtAuthHandler({
secret: useRuntimeConfig().authSecret,
pages: {
error: '/auth/error',
signOut: '/?isLogout=true',
},
providers: [CredentialsProvider.default({
name: 'credentials',
credentials: {},
async authorize(credentials: {email: string, password: string}){
const user = await UserSchema.findOne({email: credentials.email})
if (!user) {
throw createError({
statusCode: 401,
statusMessage: 'User is not found',
})
}
const isPasswordValid = await bcrypt.compare(credentials.password, user.password)
if (!isPasswordValid) {
throw createError({
statusCode: 401,
statusMessage: 'errorPasswordWrong',
})
}
return {
...user.toObject(),
password: ''
}
}
})],
session: {
strategy: 'jwt',
},
callbacks: {
async jwt({ token, user }) {
if (user) {
token.user = {
_id: user._id,
email: user.email,
}
}
return token
},
async session({ session, token }) {
const user = await UserSchema.findById(token.user._id)
session.user = user
return session
},
}
});
nuxt.config.ts
auth: {
baseURL: `${process.env.NUXT_AUTH_ORIGIN}`,
provider: {
type: 'authjs',
defaultProvider: 'credentials',
addDefaultCallbackUrl: false,
},
},
Describe the bug
I have this an error
next-auth_react.js?v=ff837320:4048 Uncaught TypeError: _interopRequireDefault2 is not a function
at node_modules/next-auth/react/index.js (next-auth_react.js?v=ff837320:4048:24)
at __require (chunk-V4OQ3NZ2.js?v=ff837320:11:50)
at next-auth_react.js?v=ff837320:4628:16
Additional context
When I run my nuxt application via npm run dev, I have this problem. But in production building I don't have it.
Logs
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
needs-reproductionAction needed: A valid reproduction of the issue needs to be addedAction needed: A valid reproduction of the issue needs to be addedprovider-authjsAn issue with the authjs providerAn issue with the authjs provider