full upgrade to dev

This commit is contained in:
2026-01-08 04:24:22 +01:00
parent e2c2585468
commit 884d7f984b
15 changed files with 2371 additions and 369 deletions

View File

@@ -7,14 +7,17 @@ export const revalidate = 30;
export async function GET() {
try {
// Rufe den n8n Webhook auf
const res = await fetch(`${process.env.N8N_WEBHOOK_URL}/denshooter-71242/status`, {
method: "GET",
headers: {
"Content-Type": "application/json",
// Add timestamp to query to bypass Cloudflare cache
const res = await fetch(
`${process.env.N8N_WEBHOOK_URL}/webhook/denshooter-71242/status?t=${Date.now()}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
next: { revalidate: 30 },
},
// Cache-Optionen für Next.js
next: { revalidate: 30 }
});
);
if (!res.ok) {
throw new Error(`n8n error: ${res.status}`);
@@ -25,6 +28,19 @@ export async function GET() {
// n8n gibt oft ein Array zurück: [{...}]. Wir wollen nur das Objekt.
const statusData = Array.isArray(data) ? data[0] : data;
// Safety check: if statusData is still undefined/null (e.g. empty array), use fallback
if (!statusData) {
throw new Error("Empty data received from n8n");
}
// Ensure coding object has proper structure
if (statusData.coding && typeof statusData.coding === "object") {
// Already properly formatted from n8n
} else if (statusData.coding === null || statusData.coding === undefined) {
// No coding data - keep as null
statusData.coding = null;
}
return NextResponse.json(statusData);
} catch (error) {
console.error("Error fetching n8n status:", error);
@@ -33,7 +49,7 @@ export async function GET() {
status: { text: "offline", color: "gray" },
music: null,
gaming: null,
coding: null
coding: null,
});
}
}
}