fix: docker fetch error log

This commit is contained in:
hamster1963 2024-10-24 13:47:45 +08:00
parent 3e9a6e1eef
commit fac484bc45
2 changed files with 11 additions and 1 deletions

View File

@ -11,6 +11,7 @@ interface NezhaDataResponse {
error?: string; error?: string;
data?: ServerApi; data?: ServerApi;
cause?: string; cause?: string;
code?: string;
} }
export const GET = auth(async function GET(req) { export const GET = auth(async function GET(req) {
@ -28,5 +29,14 @@ export const GET = auth(async function GET(req) {
{ status: 400 }, { status: 400 },
); );
} }
if (response.code === "ConnectionRefused") {
return NextResponse.json(
{ cause: "server connect error" },
{ status: 400 },
);
}
if (!response.data) {
return NextResponse.json({ cause: "fetch data empty" }, { status: 400 });
}
return NextResponse.json(response, { status: 200 }); return NextResponse.json(response, { status: 200 });
}); });

View File

@ -75,7 +75,7 @@ export async function GetNezhaData() {
return data; return data;
} catch (error) { } catch (error) {
console.error(error); console.log("GetServerDetail error:", error);
return error; return error;
} }
} }