|
@@ -1,11 +1,9 @@
|
|
|
import { serve } from 'https://deno.land/std@0.168.0/http/server.ts'
|
|
import { serve } from 'https://deno.land/std@0.168.0/http/server.ts'
|
|
|
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'
|
|
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'
|
|
|
import { wrapHandler, logError } from '../_shared/error-handler.ts'
|
|
import { wrapHandler, logError } from '../_shared/error-handler.ts'
|
|
|
|
|
+import { getCorsHeaders, handleCorsPreflightRequest } from '../_shared/cors.ts';
|
|
|
|
|
|
|
|
-const corsHeaders = {
|
|
|
|
|
- 'Access-Control-Allow-Origin': '*',
|
|
|
|
|
- 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
|
|
|
|
|
-}
|
|
|
|
|
|
|
+const corsHeaders = getCorsHeaders();
|
|
|
|
|
|
|
|
function generateOTP(): string {
|
|
function generateOTP(): string {
|
|
|
return Math.floor(100000 + Math.random() * 900000).toString()
|
|
return Math.floor(100000 + Math.random() * 900000).toString()
|
|
@@ -77,7 +75,7 @@ async function sendOTPEmail(email: string, otp: string, userName: string): Promi
|
|
|
|
|
|
|
|
serve(wrapHandler('auth', async (req) => {
|
|
serve(wrapHandler('auth', async (req) => {
|
|
|
if (req.method === 'OPTIONS') {
|
|
if (req.method === 'OPTIONS') {
|
|
|
- return new Response('ok', { headers: corsHeaders })
|
|
|
|
|
|
|
+ return handleCorsPreflightRequest()
|
|
|
}
|
|
}
|
|
|
const url = new URL(req.url)
|
|
const url = new URL(req.url)
|
|
|
const path = url.pathname.replace('/auth/', '')
|
|
const path = url.pathname.replace('/auth/', '')
|