sidebase / nuxt-auth

Authentication built for Nuxt 3! Easily add authentication via OAuth providers, credentials or Email Magic URLs!
https://auth.sidebase.io
MIT License
1.31k stars 164 forks source link

[nitro] [uncaughtException] DiscordProvider is not a function #897

Closed rarelywin closed 2 months ago

rarelywin commented 2 months ago

Environment


Reproduction

-

Describe the bug

server just not launching but should be, there is my [...].ts config

import { NuxtAuthHandler } from '#auth' import DiscordProvider from 'next-auth/providers/discord';

export default NuxtAuthHandler({ secret: useRuntimeConfig().authSecret, providers: [ DiscordProvider({ clientId: '', clientSecret: '' }) ], })

Additional context

No response

Logs

ERROR  [nitro] [uncaughtException] DiscordProvider is not a function

  at <anonymous> (server\api\auth\[...].ts:7:1)
  at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
  at async ModuleLoader.import (node:internal/modules/esm/loader:474:24)
  at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:119:5)
phoenix-ru commented 2 months ago

Please, make sure that you use .default in your configuration like so: https://github.com/sidebase/nuxt-auth/blob/ab772fdc8bed645e5f8ee518adc25f087c08dfe0/playground-authjs/server/api/auth/%5B...%5D.ts#L9-L10

It is a bug with next-auth with Vite which forces such a workaround. This won't be needed with authjs in the future.