mehedi
mehedi2mo ago

Access to fetch at 'https://adjective-animal-123.convex.site/api/auth/get-session' from origin 'http

I am using better-auth + convex + react router 7. and I am getting this below error when try to sign up Access to fetch at 'https://adjective-animal-123.convex.site/api/auth/get-session' from origin 'http://localhost:5173' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
5 Replies
Convex Bot
Convex Bot2mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Jakov
Jakov2mo ago
Oh
Jakov
Jakov2mo ago
Understanding CORS: A Developer's Guide
Cross-Origin Resource Sharing (CORS) is a crucial concept in modern web development, yet it's often misunderstood and can be a source of frustration f...
Jakov
Jakov2mo ago
import { corsRouter } from "convex-helpers/server/cors";
import { httpRouter } from "convex/server";
import { httpAction } from "./_generated/api";

const http = httpRouter();
const cors = corsRouter(http);
cors.route({
path: "/foo",
method: "GET",
handler: httpAction(async () => {
return new Response("ok");
}),
});

// now instead of http.route, use cors.route
import { corsRouter } from "convex-helpers/server/cors";
import { httpRouter } from "convex/server";
import { httpAction } from "./_generated/api";

const http = httpRouter();
const cors = corsRouter(http);
cors.route({
path: "/foo",
method: "GET",
handler: httpAction(async () => {
return new Response("ok");
}),
});

// now instead of http.route, use cors.route
instead of http.route, use cors.route
mehedi
mehediOP2mo ago
fixed thanks

Did you find this page helpful?