http request blocked by cors
Any idea why my request from localhost:3000 is still blocked by CORS? I copied the headers from a Convex sample.
I can call it from Postman but not React.
16 Replies
I run a fork of convex helpers with debugging for cors - opened a PR to add that to the library: https://github.com/get-convex/convex-helpers/pull/590
If you want to use right away, I published my fork as well, you can temporarily alias it to debug:
Thank you. Is that npm install command broken?
It shouldn't be, what are you seeing?
It's a command to install
@erquhart/convex-helpers
, but let it be named convex-helpers
in your node_modules and package.json
That way you don't have to update your code to temporarily use this forkI can't figure out the import statement
You won't change the import statement, that's the value of using an alias
And my package.json entry looks like this:
"convex-helpers": "npm:@erquhart/convex-helpers@^0.1.87",
oh shoot
:facepalm:
you're not using the cors router helper, I just read "cors" in your post and assumed you were
It does look useful
sorry, let me re-read, but you probably just need to use the regular cors helper: https://github.com/get-convex/convex-helpers/tree/main/packages/convex-helpers#cors-support-for-httprouter
GitHub
convex-helpers/packages/convex-helpers at main · get-convex/convex...
A collection of useful code to complement the official packages. - get-convex/convex-helpers
I'll give it a try, but my Convex auth randomly stopped working
Wonder if your versions changed when you did that install
Can you run this and share the output:
doesn't look like it
AuthProviderDiscoveryFailed
but there are 0 Google results
@erquhart Ok, the auth error is solved. But I'm still getting CORS error after adding the corsRouter.okay, so maybe debug will help then
Can you see anything in here?
If there's no message after that saying it was blocked, the cors helper is allowing it through
What cors error(s) are you getting specifically? Is it from options or get/post request?
The options request gets through, but the post request doesn't
Maybe it works different because the AI SDK streams the response
For anyone running into the same problem, I had to add the "Authorization" header to the options endpoint like this: