mistergena
mistergena12mo ago

Error fetching GET https://provision.convex.dev/api ....

401 Unauthorized: MissingAccessToken: An access token is required for this command. 10:10:45 AM: Authenticate with npx convex dev I am getting the same error when deploying my next js app in Vercel and Netlify. I have already setted de CONVEX_DEPLOY_KEY given in convex production environment and the NEXT_PUBLIC_CONVEX_URL pointing to the URL for production. How can I solve it ?
No description
19 Replies
erquhart
erquhart12mo ago
You have CONVEX_DEPLOY_KEY set in your Netlify/Vercel production environments?
mistergena
mistergenaOP12mo ago
Yes
No description
erquhart
erquhart12mo ago
And you're sure the deployment that's failing is production and not a preview deploy from a branch or PR?
mistergena
mistergenaOP12mo ago
Yes, look:
No description
erquhart
erquhart12mo ago
Any chance redeploys are reusing the env vars as they were in the initial deploy? Can you start a fresh production deploy rather than redeploying and see if that works
mistergena
mistergenaOP12mo ago
I am going to try, but that should not be because redeploy updates values of envs. I tried in netlify and I got the same issue, so i think that wont work but ill delete the proyect and create again in vercel.
erquhart
erquhart12mo ago
It shouldn't require deleting the project I'm only familiar with Netlify, where you can redeploy a failed build, or you can go to the main screen for the project and trigger a fresh deploy Vercel says "redeploy" everywhere so I'm just wondering if it's reusing the vars from the original deploy
mistergena
mistergenaOP12mo ago
nope, redeploys updates the values of environment vars
sshader
sshader12mo ago
Some other things to check: what version of Convex are you using? Does your CONVEX_DEPLOY_KEY look something like prod:happy-animal-123|<other stuff>?
erquhart
erquhart12mo ago
It would be really helpful if a missing deploy key and an invalid deploy key resulted in distinct error messages
mistergena
mistergenaOP12mo ago
yes: prod:dependable-hamster-161|01 .. if i do: npx convex --version 1.10.0
sshader
sshader12mo ago
Ok I'm kind of stumped but a shot in the dark -- do you have an auth.config.js and can you double check that if there are environment variables in there, (e.g. domain: process.env.CLERK_JWT_ISSUER_DOMAIN) that they're set in your prod deployment? (My theory is that we might be saying "hey you need to set these environment variables in the dashboard" but crashing with this much less helpful error when trying to give you a link to your project in the dashboard)
mistergena
mistergenaOP12mo ago
nope, i do not, should i create that file and push ?
sshader
sshader12mo ago
Hmm if you don't have that file, then sounds like my theory is wrong (It might also be called auth.config.ts, and would be in the convex folder in case you have that)
mistergena
mistergenaOP12mo ago
I do, I have this: export default { providers: [ { domain: https://${process.env.CLERK_HOSTNAME}/, applicationID: "convex", }, ], };
sshader
sshader12mo ago
Convex Dashboard
Manage your Convex apps
mistergena
mistergenaOP12mo ago
Finally, I could deploy it. Thanks sshader ❣️ Should i add all vercel environments vars to convex?
sshader
sshader12mo ago
The only ones you need to set in Convex are the ones used in the convex/ folder (so the auth config one, and if you have Convex functions that read from process.env.FOO) npx convex deploy was trying to print a helpful message that you need to set CLERK_HOSTNAME with a link, but unhelpfully failing when trying to actually assemble the link 😅
Hashimoto
Hashimoto12mo ago
@sshader Thank you very much. The same thing was happening, but by setting the value of Issuer of Clerk JWT Template to CLERK_JWT_ISSUER_DOMAIN in [Covex Dashboard] - [Prod] - [Settings] - [Environment Variables] Deployment succeeded.

Did you find this page helpful?