export const config = { runtime: 'edge' }; import { getCorsHeaders, isDisallowedOrigin } from './_cors.js'; import { getCacheTelemetrySnapshot } from './_cache-telemetry.js'; export default async function handler(req) { const corsHeaders = getCorsHeaders(req, 'GET, OPTIONS'); if (req.method === 'OPTIONS') { if (isDisallowedOrigin(req)) { return new Response(null, { status: 403, headers: corsHeaders }); } return new Response(null, { status: 204, headers: corsHeaders }); } if (req.method !== 'GET') { return new Response(JSON.stringify({ error: 'Method not allowed' }), { status: 405, headers: { 'Content-Type': 'application/json', ...corsHeaders }, }); } if (isDisallowedOrigin(req)) { return new Response(JSON.stringify({ error: 'Origin not allowed' }), { status: 403, headers: { 'Content-Type': 'application/json', ...corsHeaders }, }); } return new Response(JSON.stringify(getCacheTelemetrySnapshot()), { status: 200, headers: { 'Content-Type': 'application/json', 'Cache-Control': 'no-store', ...corsHeaders, }, }); }