|
|
@@ -8,11 +8,16 @@ const corsHeaders = {
|
|
|
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
|
|
}
|
|
|
|
|
|
-serve(wrapHandler('api', async (req) => {
|
|
|
+// Handle OPTIONS requests BEFORE wrapping with error handler to avoid timeouts
|
|
|
+serve(async (req) => {
|
|
|
+ // Fast-path for OPTIONS requests
|
|
|
if (req.method === 'OPTIONS') {
|
|
|
return new Response('ok', { headers: corsHeaders })
|
|
|
}
|
|
|
|
|
|
+ // Wrap all other requests with error handler
|
|
|
+ return wrapHandler('api', async (req) => {
|
|
|
+
|
|
|
try {
|
|
|
const url = new URL(req.url)
|
|
|
const path = url.pathname.replace('/api/', '')
|
|
|
@@ -1680,4 +1685,5 @@ serve(wrapHandler('api', async (req) => {
|
|
|
{ status: 500, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
|
|
|
)
|
|
|
}
|
|
|
-}))
|
|
|
+ })(req)
|
|
|
+})
|