fix: resolve NextAuth UntrustedHost error and add login debugging

- Add trustHost: true to NextAuth configuration
- Add console logging for login debugging
- Fix authentication issues preventing login redirect
This commit is contained in:
张翔
2026-03-13 12:38:13 +08:00
parent 46e851bc3a
commit 8c82ce5bad
2 changed files with 7 additions and 0 deletions
+6
View File
@@ -44,18 +44,24 @@ function LoginForm() {
setLoading(true);
try {
console.log('开始登录...', { email, callbackUrl });
const result = await signIn('credentials', {
email,
password,
redirect: false,
});
console.log('登录结果:', result);
if (result?.error) {
console.error('登录错误:', result.error);
setError('邮箱或密码错误');
} else {
console.log('登录成功,准备跳转到:', callbackUrl);
router.push(callbackUrl);
}
} catch (err) {
console.error('登录异常:', err);
setError('登录失败,请稍后重试');
} finally {
setLoading(false);