15 Replies
Can you paste the output of
curl -v $YOUR SITE
?
so we can see the headers coming from the http action?➜ curl -v https://calculating-xyz.convex.site/test
I don't see the header in there
next question
in your convex dashboard
npx convex dashboard
, do you see this http action having the code body you expect?
ah, actually. I see the issue. this was a 404
so the router isn't working. what does your route adding code look like? and are you default exporting a router from a file called http.ts
?http.route({
path: "/test",
method: "OPTIONS",
handler: httpAction(async (_, request) => {
// Make sure the necessary headers are present
// for this to be a valid pre-flight request
const headers = request.headers;
if (
headers.get("Origin") !== null &&
headers.get("Access-Control-Request-Method") !== null &&
headers.get("Access-Control-Request-Headers") !== null
) {
return new Response(null, {
headers: new Headers({
// e.g. https://mywebsite.com
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "POST",
"Access-Control-Allow-Headers": "Content-Type",
"Access-Control-Max-Age": "86400",
"Content-Type": "application/json",
}),
});
} else {
return new Response();
}
}),
});
// Define additional routes
http.route({
path: "/test",
method: "POST",
handler: doSomething,
});
copy pasta from the docs
basically
and that
http
object is exported? double checking that, but then our curl test probably didn't work because it was a GET
cool
and everything looks good in the dashboard? the functions are syncing,
npx convex dev
is up and running?curl -d '{ "data": [], "apiKey": "Hello world" }' \
-H 'content-type: application/json' "https://calculating-xyz.convex.site/test"
{"code":"Uncaught Error: Uncaught something "}% -> is error is probably from the internalAction that i'm running wowo just realize your the ceo of convex just for the personal portfolio website you build a whole baas 😁
{"code":"Uncaught Error: Uncaught something "}% -> is error is probably from the internalAction that i'm running wowo just realize your the ceo of convex just for the personal portfolio website you build a whole baas 😁
🙂
next step I'd ask is if you can go into chrome devtools and watch the network request go by. do you see the OPTIONS request to your site? we can inspect the headers to make sure everything is okay there
ok i think i got the issue so basically the internalAction was doing processing on bunch of data and in some cases it fails and throws error

and the fetch some how shows cors error in this case
ah, interesting
Ya, i double checked it.
If the internal action doesn't fail in any case then it doesn't give any sort of error