Add health check edge function (#26823)

This commit is contained in:
Joshen Lim authored and GitHub committed 2024-05-31 10:21:23 +08:00
1 parent 97853287f3
commit 65eb68b0ee
1 file changed
+21
+21
View File
@@ -0,0 +1,21 @@
import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
serve(async (req) => {
const data = { healthy: true };
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "POST",
"Access-Control-Allow-Headers":
"authorization, x-request-id, apikey, content-type, user-agent, sec-ch-ua, sec-ch-ua-mobile, sec-ch-ua-platform, referer, accept",
};
// This is needed if you're planning to invoke your function from a browser.
if (req.method === "OPTIONS") {
return new Response("ok", { headers: corsHeaders });
}
return new Response(JSON.stringify(data), {
headers: { ...corsHeaders, "Content-Type": "application/json" },
status: 200,
});
});