[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
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 2m55s
This commit is contained in:
@ -24,10 +24,18 @@ export function LoginPage() {
|
|||||||
navigate(redirectTo, { replace: true })
|
navigate(redirectTo, { replace: true })
|
||||||
toast.success('Đăng nhập thành công')
|
toast.success('Đăng nhập thành công')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const msg = axios.isAxiosError(err)
|
let msg: string
|
||||||
? err.response?.data?.detail ?? err.response?.data?.title ?? err.message
|
if (axios.isAxiosError(err)) {
|
||||||
: 'Lỗi kết nối máy chủ'
|
if (err.code === 'ERR_NETWORK' || err.message === 'Network Error') {
|
||||||
toast.error(`Đăng nhập thất bại: ${msg}`)
|
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 {
|
} finally {
|
||||||
setIsSubmitting(false)
|
setIsSubmitting(false)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,10 +24,18 @@ export function LoginPage() {
|
|||||||
navigate(redirectTo, { replace: true })
|
navigate(redirectTo, { replace: true })
|
||||||
toast.success('Đăng nhập thành công')
|
toast.success('Đăng nhập thành công')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const msg = axios.isAxiosError(err)
|
let msg: string
|
||||||
? err.response?.data?.detail ?? err.response?.data?.title ?? err.message
|
if (axios.isAxiosError(err)) {
|
||||||
: 'Lỗi kết nối máy chủ'
|
if (err.code === 'ERR_NETWORK' || err.message === 'Network Error') {
|
||||||
toast.error(`Đăng nhập thất bại: ${msg}`)
|
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 {
|
} finally {
|
||||||
setIsSubmitting(false)
|
setIsSubmitting(false)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user