Skip to content

Commit 79ac7d1

Browse files
authored
Merge pull request #114 from design-sparx/claude/fix-credentials-signin-error-016Ak3EEbqqx5HBK8eDtNw3d
fix: add detailed logging to auth authorize function
2 parents 358e3ea + 1b4fc84 commit 79ac7d1

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

app/lib/authOptions.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)