mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
Merge branch 'main' into cloudflare
This commit is contained in:
commit
13ba1f8ac4
@ -12,6 +12,8 @@ export const dynamic = "force-dynamic";
|
|||||||
interface NezhaDataResponse {
|
interface NezhaDataResponse {
|
||||||
error?: string;
|
error?: string;
|
||||||
data?: NezhaAPISafe;
|
data?: NezhaAPISafe;
|
||||||
|
cause?: string;
|
||||||
|
code?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GET = auth(async function GET(req) {
|
export const GET = auth(async function GET(req) {
|
||||||
@ -34,5 +36,19 @@ export const GET = auth(async function GET(req) {
|
|||||||
console.log(response.error);
|
console.log(response.error);
|
||||||
return NextResponse.json({ error: response.error }, { status: 400 });
|
return NextResponse.json({ error: response.error }, { status: 400 });
|
||||||
}
|
}
|
||||||
|
if (response.cause) {
|
||||||
|
console.log("GetServerDetail error(cause):", response);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ cause: "server connect error" },
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (response.code === "ConnectionRefused") {
|
||||||
|
console.log("GetServerDetail error(code):", response);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ cause: "server connect error" },
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
}
|
||||||
return NextResponse.json(response, { status: 200 });
|
return NextResponse.json(response, { status: 200 });
|
||||||
});
|
});
|
||||||
|
@ -12,6 +12,8 @@ export const dynamic = "force-dynamic";
|
|||||||
interface NezhaDataResponse {
|
interface NezhaDataResponse {
|
||||||
error?: string;
|
error?: string;
|
||||||
data?: ServerMonitorChart;
|
data?: ServerMonitorChart;
|
||||||
|
cause?: string;
|
||||||
|
code?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GET = auth(async function GET(req) {
|
export const GET = auth(async function GET(req) {
|
||||||
@ -34,5 +36,19 @@ export const GET = auth(async function GET(req) {
|
|||||||
console.log(response.error);
|
console.log(response.error);
|
||||||
return NextResponse.json({ error: response.error }, { status: 400 });
|
return NextResponse.json({ error: response.error }, { status: 400 });
|
||||||
}
|
}
|
||||||
|
if (response.cause) {
|
||||||
|
console.log("GetServerMonitor error(cause):", response);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ cause: "server connect error" },
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (response.code === "ConnectionRefused") {
|
||||||
|
console.log("GetServerMonitor error(code):", response);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ cause: "server connect error" },
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
}
|
||||||
return NextResponse.json(response, { status: 200 });
|
return NextResponse.json(response, { status: 200 });
|
||||||
});
|
});
|
||||||
|
@ -13,6 +13,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) {
|
||||||
@ -25,10 +26,21 @@ export const GET = auth(async function GET(req) {
|
|||||||
return NextResponse.json({ error: response.error }, { status: 400 });
|
return NextResponse.json({ error: response.error }, { status: 400 });
|
||||||
}
|
}
|
||||||
if (response.cause) {
|
if (response.cause) {
|
||||||
|
console.log("GetNezhaData error(cause):", response);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ cause: "server connect error" },
|
{ cause: "server connect error" },
|
||||||
{ status: 400 },
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (response.code === "ConnectionRefused") {
|
||||||
|
console.log("GetNezhaData error(code):", response);
|
||||||
|
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 });
|
||||||
});
|
});
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user