Created
September 13, 2023 17:19
-
-
Save mansueli/ff85d2e859d87b69aa3734925ce5a721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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