Files
acmcc/supabase/functions/get-mapbox-token/index.ts
2026-06-01 20:19:26 -04:00

19 lines
837 B
TypeScript

// Returns the Mapbox public token for client-side map rendering.
// Public tokens (pk.*) are safe to expose; we fetch via edge function so
// the token can be rotated without redeploying the frontend.
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers":
"authorization, x-client-info, apikey, content-type, x-supabase-client-platform, x-supabase-client-platform-version, x-supabase-client-runtime, x-supabase-client-runtime-version",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
};
Deno.serve((req) => {
if (req.method === "OPTIONS") return new Response("ok", { headers: corsHeaders });
const token = Deno.env.get("MAPBOX_PUBLIC_TOKEN") || "";
return new Response(JSON.stringify({ token }), {
headers: { ...corsHeaders, "Content-Type": "application/json" },
});
});