nikiv.dev
nikiv.dev2mo ago

how to avoid CORS on convex functions

how to avoid CORS on convex functions I have SITE_URL set correctly
64 Replies
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
I have a request being made to 'https://charming-raccoon-146.convex.site/api/auth/email-otp/send-verification-otp from my client but its blocked by cors
nikiv.dev
nikiv.devOP2mo ago
actually all requests do this https://gen.new/
No description
nikiv.dev
nikiv.devOP2mo ago
ok checking, maybe i need to add something to requests oo i think in convex dash i need to have approved domains most likely
nikiv.dev
nikiv.devOP2mo ago
ok that seems pro plan only feature
No description
nikiv.dev
nikiv.devOP2mo ago
in theory
No description
nikiv.dev
nikiv.devOP2mo ago
this should be a fix against cors as I am making requests from that origin
erquhart
erquhart2mo ago
Using Better Auth? There's a Convex integration for it, unless you're intentionally rolling your own
nikiv.dev
nikiv.devOP2mo ago
yea I am using better auth
erquhart
erquhart2mo ago
Not using the Convex + Better Auth component on purpose?
nikiv.dev
nikiv.devOP2mo ago
GitHub
GitHub - genxai/new: Generate anything. Personalized. Any model.
Generate anything. Personalized. Any model. Contribute to genxai/new development by creating an account on GitHub.
nikiv.dev
nikiv.devOP2mo ago
let me check the auth part
erquhart
erquhart2mo ago
Ah looking at the starter you linked in the readme
nikiv.dev
nikiv.devOP2mo ago
yea i also asked @Topf maybe he knows i assumed he used that but i added the envs proper to vercel that is and convex dash
erquhart
erquhart2mo ago
Yep it's using it, and it appears to be set up correctly to avoid cors issues rereading your messages here Just looking at your screenshot, you put gen.new as SITE_URL, but the error you shared says your domain is dev.gen.new
nikiv.dev
nikiv.devOP2mo ago
i tried on gen.new dev. was old thing let me check maybe i have it in code defined
nikiv.dev
nikiv.devOP2mo ago
nop
No description
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
in vercel
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
favicon will fix now where did you see dev.gen.new i thought i removed all traces of it that was just a test subdomain
nikiv.dev
nikiv.devOP2mo ago
a true ok yea that was old screen https://gen.new/ you can replicate cors here too and thats with all sites pointing to gen.new by sites i mean vercel and convex dash
erquhart
erquhart2mo ago
Check your logs in the convex dashboard, there may be some clues there
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
or there are other logs
nikiv.dev
nikiv.devOP2mo ago
No description
erquhart
erquhart2mo ago
Click logs on the left
nikiv.dev
nikiv.devOP2mo ago
oo til
nikiv.dev
nikiv.devOP2mo ago
mm
No description
erquhart
erquhart2mo ago
Have you run convex dev yet
nikiv.dev
nikiv.devOP2mo ago
i commit generated files
erquhart
erquhart2mo ago
yeah you're supposed to
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
should i maybe
erquhart
erquhart2mo ago
Yeah you need to run convex dev
nikiv.dev
nikiv.devOP2mo ago
change build to run npx convex dev && bun run build?
erquhart
erquhart2mo ago
First, is this happening in dev
nikiv.dev
nikiv.devOP2mo ago
dev is ok no errors
erquhart
erquhart2mo ago
Or working in dev and only failing in production ah
nikiv.dev
nikiv.devOP2mo ago
its only in prod its failing "build": "vite build", is my build now
nikiv.dev
nikiv.devOP2mo ago
yea i read this doc and followed it like i have CONVEX_DEPLOY_KEY
erquhart
erquhart2mo ago
The build command Template doesn't have a production build command, you need to follow all the steps in the doc there
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
oh so you mean override build in vercel i remember trying this and i was getting issues ok let me try again
nikiv.dev
nikiv.devOP2mo ago
woow
No description
nikiv.dev
nikiv.devOP2mo ago
no cors any more only email doesn't send tho mm but will debug that now thanks a lot @erquhart
erquhart
erquhart2mo ago
Check your resend dashboard, might be in test mode attempting to send to an email address other than the one you're allowed to use for test
nikiv.dev
nikiv.devOP2mo ago
no emails sent from resend, its like its not even reaching it also i dont get why
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
but no logs reach vercel for some reason for my other projects everything is ok super weird
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
it seems its because i need some kind of vercel adapter on top of react or smth its strange tho cause i remember vercel being able to consume any browser logs ok going to fix the logs issue first, then why resend is not sending mails (i think it just doesn't reach it)
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
ok i think i get it
No description
nikiv.dev
nikiv.devOP2mo ago
in here I don't actually set from what email it should send it from
No description
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
although maybe SITE_URL would be used i'd think
nikiv.dev
nikiv.devOP2mo ago
ok im silly
No description
nikiv.dev
nikiv.devOP2mo ago
thats the env i need to set still doesn't send the email on new build too
erquhart
erquhart2mo ago
For posterity this thread was continued and resolved here: https://discord.com/channels/1019350475847499849/1420406955301929043

Did you find this page helpful?