@@ -12,24 +12,23 @@ Deno.serve(async (req) => {
1212 status : 204 ,
1313 headers : {
1414 "Content-Type" : "application/json" ,
15- "Access-Control-Allow-Origin" : "https://compnus.github.io" ,
15+ "Access-Control-Allow-Origin" : "https://compnus.github.io" ,
1616 "Access-Control-Allow-Methods" : "GET, POST, PUT, DELETE, OPTIONS" ,
17- "Access-Control-Allow-Headers" : "Content-Type, Authorization" ,
17+ "Access-Control-Allow-Headers" : "Content-Type, Authorization"
1818 }
19- } )
19+ } ) ;
2020 }
2121
22- const authHeader = req . headers . get ( 'Authorization' )
22+ // Check Authorization header
23+ const authHeader = req . headers . get ( 'Authorization' ) ;
2324 if ( ! authHeader ) {
24- return new Response ( 'Authorization header missing' , { status : 401 } )
25+ return new Response ( 'Authorization header missing' , { status : 401 } ) ;
2526 }
2627
27- const token = authHeader . split ( ' ' ) [ 1 ] // Bearer token
28-
29- // Verify the token using Supabase client SDK (make sure supabase client is initialized)
30- const { data : user , error } = await supabase . auth . api . getUser ( token )
28+ const token = authHeader . split ( ' ' ) [ 1 ] ;
29+ const { data : user , error } = await supabase . auth . api . getUser ( token ) ;
3130 if ( error || ! user ) {
32- return new Response ( 'Invalid JWT' , { status : 401 } )
31+ return new Response ( 'Invalid JWT' , { status : 401 } ) ;
3332 }
3433
3534 let uid : string | null = null ;
@@ -83,12 +82,11 @@ Deno.serve(async (req) => {
8382 "Content-Type" : "application/json" ,
8483 "Access-Control-Allow-Origin" : "https://compnus.github.io" ,
8584 "Access-Control-Allow-Methods" : "GET, POST, PUT, DELETE, OPTIONS" ,
86- "Access-Control-Allow-Headers" : "Content-Type, Authorization" ,
85+ "Access-Control-Allow-Headers" : "Content-Type, Authorization"
8786 }
8887 } ) ;
8988 } catch ( error ) {
9089 console . error ( "Error processing request" , error ) ;
9190 return new Response ( "Internal Server Error." , { status : 500 } ) ;
9291 }
9392} ) ;
94-
0 commit comments