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