@@ -9,6 +9,7 @@ import type { NextAuthConfig } from '../../../module'
99
1010// @ts -ignore Virtual import declared in `module.ts` - TODO: make the import discoverable
1111import nextConfig from '#sidebase/auth'
12+ import bundlesProviders from '#sidebase/providers'
1213
1314// TODO: Make `NEXTAUTH_URL` configurable
1415const NEXTAUTH_URL = nextConfig . url ? parseURL ( nextConfig . url ) : parseURL ( 'http://localhost:3000/api/auth/' )
@@ -20,17 +21,17 @@ let loadedNextConfig: NextAuthConfig | undefined
2021/**
2122 * Generate the next auth config that can be used for handling requests
2223 */
23- const getNextConfig = async ( ) : Promise < NextAuthConfig > => {
24+ const getNextConfig = ( ) : NextAuthConfig => {
2425 if ( loadedNextConfig ) {
2526 return loadedNextConfig
2627 }
2728
28- const providers = await Promise . all ( nextConfig . options . providers . map ( async ( providerConfig ) => {
29- const provider = await import ( `next-auth/providers/ ${ providerConfig . id } ` )
29+ const providers = nextConfig . options . providers . map ( ( providerConfig ) => {
30+ const provider = bundlesProviders [ providerConfig . id ]
3031
3132 // Import is exported on .default during SSR, so we need to call `.default.default` here
32- return provider . default . default ( providerConfig . options )
33- } ) )
33+ return provider . default ( providerConfig . options )
34+ } )
3435
3536 const finalConfig = {
3637 ...nextConfig ,
@@ -120,7 +121,7 @@ const readBodyForNext = async (event: H3Event) => {
120121 * @param event H3Event event to transform into `RequestInternal`
121122 */
122123const getInternalNextAuthRequestData = async ( event : H3Event ) : Promise < RequestInternal > => {
123- const { url } = await getNextConfig ( )
124+ const { url } = getNextConfig ( )
124125 const nextRequest : RequestInternal = {
125126 host : url ,
126127 body : undefined ,
@@ -185,7 +186,7 @@ export const authHandler = async (event: H3Event) => {
185186 }
186187
187188 // 2. Assemble and perform request to the NextAuth.js auth handler
188- const nextConfig = await getNextConfig ( )
189+ const nextConfig = getNextConfig ( )
189190 const nextRequest = await getInternalNextAuthRequestData ( event )
190191
191192 const nextResult = await NextAuthHandler ( {
0 commit comments