2026-08-20 22:14:32 +01:00
|
|
|
import { NextResponse } from 'next/server';
|
|
|
|
|
import { proxySitemap } from '@/lib/sitemapProxy';
|
|
|
|
|
|
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
|
export const runtime = 'nodejs';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Children are /sitemaps/static.xml and /sitemaps/schools-{n}.xml. The name is
|
|
|
|
|
* validated here rather than passed through, so this route cannot be used to
|
|
|
|
|
* reach arbitrary backend paths.
|
|
|
|
|
*/
|
2026-08-21 18:13:55 +01:00
|
|
|
const CHILD = /^(static|schools-\d+|places-\d+|outcodes-\d+)\.xml$/;
|
2026-08-20 22:14:32 +01:00
|
|
|
|
|
|
|
|
export async function GET(
|
|
|
|
|
_request: Request,
|
|
|
|
|
{ params }: { params: Promise<{ parts: string[] }> },
|
|
|
|
|
) {
|
|
|
|
|
const { parts } = await params;
|
|
|
|
|
const name = parts.join('/');
|
|
|
|
|
if (!CHILD.test(name)) {
|
|
|
|
|
return new NextResponse('Not found', { status: 404 });
|
|
|
|
|
}
|
|
|
|
|
return proxySitemap(`/sitemaps/${name}`);
|
|
|
|
|
}
|