Skip to content

Instantly share code, notes, and snippets.

@mansueli
Created September 13, 2023 17:19
Show Gist options
  • Save mansueli/ff85d2e859d87b69aa3734925ce5a721 to your computer and use it in GitHub Desktop.
Save mansueli/ff85d2e859d87b69aa3734925ce5a721 to your computer and use it in GitHub Desktop.
import { serve } from "https://deno.land/std@0.200.0/http/server.ts"
console.log("Hello from Functions!")
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers":
"authorization, x-client-info, apikey, content-type",
};
serve(async (req) => {
if (req.method === 'OPTIONS') {
return new Response('ok', { headers: corsHeaders })
}
const { name } = await req.json()
const data = {
message: `Hello 200 ${name}!`,
}
return new Response(
JSON.stringify(data),
{ headers: { ...corsHeaders, "Content-Type": "application/json" } },
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment