[CLAUDE] FE: login error message hướng dẫn diagnose khi Network Error
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 2m55s

This commit is contained in:
pqhuy1987
2026-04-21 15:46:04 +07:00
parent 02b8d4be52
commit c73e3f904b
2 changed files with 24 additions and 8 deletions

View File

@ -24,10 +24,18 @@ export function LoginPage() {
navigate(redirectTo, { replace: true })
toast.success('Đăng nhập thành công')
} catch (err) {
const msg = axios.isAxiosError(err)
? err.response?.data?.detail ?? err.response?.data?.title ?? err.message
: 'Lỗi kết nối máy chủ'
toast.error(`Đăng nhập thất bại: ${msg}`)
let msg: string
if (axios.isAxiosError(err)) {
if (err.code === 'ERR_NETWORK' || err.message === 'Network Error') {
const apiUrl = (import.meta.env.VITE_API_BASE_URL ?? window.location.origin) + '/api'
msg = `Không thể kết nối ${apiUrl}. Check dev tools F12 → Network. Có thể do cache cũ — thử Ctrl+Shift+R hoặc tab ẩn danh.`
} else {
msg = err.response?.data?.detail ?? err.response?.data?.title ?? err.message
}
} else {
msg = 'Lỗi không xác định'
}
toast.error(`Đăng nhập thất bại: ${msg}`, { duration: 8000 })
} finally {
setIsSubmitting(false)
}