Minor fixes.
This commit is contained in:
parent
418a30f062
commit
18033667d3
@ -10,7 +10,9 @@ export default function HealthStatus() {
|
||||
const checkHealth = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await fetch(`${process.env.BACKEND_URL}/health`);
|
||||
const response = await fetch(`${process.env.BACKEND_URL}/health`, {
|
||||
credentials: "include",
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Server responded with status: ${response.status}`);
|
||||
@ -19,7 +21,7 @@ export default function HealthStatus() {
|
||||
let data;
|
||||
try {
|
||||
data = await response.json();
|
||||
} catch (jsonErr) {
|
||||
} catch {
|
||||
setError("Response is not valid JSON");
|
||||
setHealth({});
|
||||
return;
|
||||
|
||||
@ -46,7 +46,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
let userData;
|
||||
try {
|
||||
userData = await response.json();
|
||||
} catch (jsonErr) {
|
||||
} catch {
|
||||
// 不是 JSON,降级处理
|
||||
setUser(null);
|
||||
setIsAuthenticated(false);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user