ConvexAuth Env Variable related Error in Production

Hey, I am getting this error in my convex production deployment:
Jun 30, 19:08:38.406
failure

15ms
M

auth:store
Uncaught TypeError: "pkcs8" must be PKCS#8 formatted string
at importPKCS8 (../../node_modules/jose/dist/browser/key/import.js:20:4)
at generateToken (../../node_modules/@convex-dev/auth/src/server/implementation/tokens.ts:16:25)
at generateTokensForSession (../../node_modules/@convex-dev/auth/src/server/implementation/sessions.ts:77:18)
at async maybeGenerateTokensForSession (../../node_modules/@convex-dev/auth/src/server/implementation/sessions.ts:32:10)
at async signInImpl (../../node_modules/@convex-dev/auth/src/server/implementation/mutations/signIn.ts:34:0)
Jun 30, 19:08:38.406
failure

15ms
M

auth:store
Uncaught TypeError: "pkcs8" must be PKCS#8 formatted string
at importPKCS8 (../../node_modules/jose/dist/browser/key/import.js:20:4)
at generateToken (../../node_modules/@convex-dev/auth/src/server/implementation/tokens.ts:16:25)
at generateTokensForSession (../../node_modules/@convex-dev/auth/src/server/implementation/sessions.ts:77:18)
at async maybeGenerateTokensForSession (../../node_modules/@convex-dev/auth/src/server/implementation/sessions.ts:32:10)
at async signInImpl (../../node_modules/@convex-dev/auth/src/server/implementation/mutations/signIn.ts:34:0)
I am using ConvexAuth and I think this error is related to JWT_PRIVATE_KEY env variable, but I have set it up correctly, in my Vercel Env variables as well and Convex Production deployment's env variables as well, then why am i getting this error? And Someone please tell me, What Env variables are necessary to setup the Convex Production deployment, especially with ConvexAuth on Vercel. Like Which Env Variables needed to set on Convex's Dashboard and which for Vercel Dashboard's Env variables, when we are deploying our project to production. I have generate the "CONVEX_DEPLOY_KEY" from my project's production side, and added it in Vercel Env and changed Build command as described in the Hosting guide of convex.
3 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!
Chandrabhan Singh
Chandrabhan SinghOP2mo ago
I am getting this error, when I am submitting the signup form. and I am not getting this error during my local development.
erquhart
erquhart2mo ago
The issue is your JWT_PRIVATE_KEY as you said, but Vercel is not involved as this variable is only needed in your Convex deployment. Your production env var has some kind of issue. I'd recommend printing (not sharing here, obviously) your dev and prod values for this variable to see if there's a difference in formatting or something.
npx convex env get JWT_PRIVATE_KEY
npx convex env get JWT_PRIVATE_KEY --prod
npx convex env get JWT_PRIVATE_KEY
npx convex env get JWT_PRIVATE_KEY --prod
That will print both so you can check the values

Did you find this page helpful?