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 ?
19 Replies
You have CONVEX_DEPLOY_KEY set in your Netlify/Vercel production environments?
Yes

And you're sure the deployment that's failing is production and not a preview deploy from a branch or PR?
Yes, look:

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
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.
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
nope, redeploys updates the values of environment vars
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>
?It would be really helpful if a missing deploy key and an invalid deploy key resulted in distinct error messages
yes: prod:dependable-hamster-161|01 ..
if i do:
npx convex --version
1.10.0
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)nope, i do not, should i create that file and push ?
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)I do, I have this:
export default {
providers: [
{
domain:
https://${process.env.CLERK_HOSTNAME}/
,
applicationID: "convex",
},
],
};Ok can you check that
CLERK_HOSTNAME
is set in https://dashboard.convex.dev/d/dependable-hamster-161/settings/environment-variablesConvex Dashboard
Manage your Convex apps
Finally, I could deploy it. Thanks sshader ❣️
Should i add all vercel environments vars to convex?
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 😅@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.