@@ -117,23 +117,38 @@ export const authOptions: NextAuthOptions = {
117117 } ,
118118 async authorize ( credentials ) {
119119 try {
120- const res = await fetch (
121- `${ process . env . NEXT_PUBLIC_API_URL } /api/v1/auth/login` ,
122- {
123- method : 'POST' ,
124- headers : { 'Content-Type' : 'application/json' } ,
125- body : JSON . stringify ( {
126- email : credentials ?. email ,
127- password : credentials ?. password ,
128- } ) ,
129- } ,
130- ) ;
120+ const apiUrl = `${ process . env . NEXT_PUBLIC_API_URL } /api/v1/auth/login` ;
121+ console . log ( '🔐 Attempting login to:' , apiUrl ) ;
122+ console . log ( '📧 Email:' , credentials ?. email ) ;
123+
124+ const res = await fetch ( apiUrl , {
125+ method : 'POST' ,
126+ headers : { 'Content-Type' : 'application/json' } ,
127+ body : JSON . stringify ( {
128+ email : credentials ?. email ,
129+ password : credentials ?. password ,
130+ } ) ,
131+ } ) ;
132+
133+ console . log ( '📡 Response status:' , res . status , res . statusText ) ;
131134
132135 if ( ! res . ok ) {
136+ let errorBody ;
137+ try {
138+ errorBody = await res . json ( ) ;
139+ } catch {
140+ errorBody = await res . text ( ) ;
141+ }
142+ console . error ( '❌ Login failed:' , {
143+ status : res . status ,
144+ statusText : res . statusText ,
145+ error : errorBody ,
146+ } ) ;
133147 return null ;
134148 }
135149
136150 const response = await res . json ( ) ;
151+ console . log ( '✅ Login successful, response keys:' , Object . keys ( response ) ) ;
137152
138153 // If your JWT already contains the permissions
139154 // You can extract the payload portion without validating the signature
0 commit comments