29 lines
981 B
TypeScript
29 lines
981 B
TypeScript
import {NextResponse} from "next/server";
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
export async function GET() {
|
|
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || "https://dki.one"; // Stelle sicher, dass die Base-URL korrekt ist
|
|
const apiUrl = `${baseUrl}/api/sitemap`; // Verwende die vollständige URL zur API
|
|
|
|
try {
|
|
// Holt die Sitemap-Daten von der API
|
|
const res = await fetch(apiUrl);
|
|
|
|
if (!res.ok) {
|
|
console.error(`Failed to fetch sitemap: ${res.statusText}`);
|
|
return new NextResponse("Failed to fetch sitemap", {status: 500});
|
|
}
|
|
|
|
const xml = await res.text();
|
|
|
|
// Gibt die XML mit dem richtigen Content-Type zurück
|
|
return new NextResponse(xml, {
|
|
headers: {"Content-Type": "application/xml"},
|
|
});
|
|
} catch (error) {
|
|
console.error("Error fetching sitemap:", error);
|
|
return new NextResponse("Error fetching sitemap", {status: 500});
|
|
}
|
|
}
|