Error on calling edge function from react app
I have facing issues when I call a function from client app that check website is alive or not from supabase function. I have tested on postman and its all ok but not ok when i call invoke function from react app.



5 Replies
// Setup type definitions for built-in Supabase Runtime APIs
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import { corsHeaders } from "../_shared/cors.ts";
Deno.serve(async (req) => {
if (req.method === "OPTIONS") {
return new Response("ok", {
headers: corsHeaders,
});
}
try {
const { url } = await req.json();
if (!url || typeof url !== "string") {
return new Response(
JSON.stringify({
error: "Missing or invalid 'url' property",
}),
{
headers: {
...corsHeaders,
"Content-Type": "application/json",
},
status: 400,
},
);
}
// Clean the URL by removing `/api/v1/...` if present
const urlSplit = url.split("/api/v1/");
const strippedUrl = urlSplit.length > 1 ? urlSplit[0] + "/" : url;
let enabled = false;
try {
const response = await fetch(strippedUrl, {
method: "GET",
});
enabled = response.ok;
} catch (_) {
enabled = false;
}
return new Response(
JSON.stringify({
enabled,
}),
{
headers: {
...corsHeaders,
"Content-Type": "application/json",
"Connection": "keep-alive",
},
status: 200,
},
);
} catch (error) {
return new Response(
JSON.stringify({
error: error instanceof Error ? error.message : String(error),
}),
{
headers: {
...corsHeaders,
"Content-Type": "application/json",
},
status: 400,
},
);
}
});
// Setup type definitions for built-in Supabase Runtime APIs
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import { corsHeaders } from "../_shared/cors.ts";
Deno.serve(async (req) => {
if (req.method === "OPTIONS") {
return new Response("ok", {
headers: corsHeaders,
});
}
try {
const { url } = await req.json();
if (!url || typeof url !== "string") {
return new Response(
JSON.stringify({
error: "Missing or invalid 'url' property",
}),
{
headers: {
...corsHeaders,
"Content-Type": "application/json",
},
status: 400,
},
);
}
// Clean the URL by removing `/api/v1/...` if present
const urlSplit = url.split("/api/v1/");
const strippedUrl = urlSplit.length > 1 ? urlSplit[0] + "/" : url;
let enabled = false;
try {
const response = await fetch(strippedUrl, {
method: "GET",
});
enabled = response.ok;
} catch (_) {
enabled = false;
}
return new Response(
JSON.stringify({
enabled,
}),
{
headers: {
...corsHeaders,
"Content-Type": "application/json",
"Connection": "keep-alive",
},
status: 200,
},
);
} catch (error) {
return new Response(
JSON.stringify({
error: error instanceof Error ? error.message : String(error),
}),
{
headers: {
...corsHeaders,
"Content-Type": "application/json",
},
status: 400,
},
);
}
});
Have you checked your edge function logs to see what error it shows?
this is in my local



edge function log are not showing in self host supabase