Rane
Rane7d ago

Convex Auth in production

Hi everyone, I’m deploying my Vite React app to Railway from a GitHub repo with Convex, and I’ve run into an issue. My build script works fine with:
"build": "tsc -b && vite build && npx convex deploy"
However, when I add Convex Auth initialization for production:
"build": "tsc -b && vite build && npx convex deploy && npx @convex-dev/auth --prod"
the deployment fails with the following error:
! No source control detected. We strongly recommend committing the current state of your code before proceeding. ... ERROR: failed to solve: process "/bin/bash -ol pipefail -c tsc -b && npx convex deploy && vite build && npx @convex-dev/auth --prod" did not complete successfully: exit code: 130
My current scripts:
"scripts": { "dev": "vite", "build": "tsc -b && vite build && npx convex deploy && npx @convex-dev/auth --prod", "lint": "eslint .", "preview": "vite preview" }
Is this the right way to initialize Convex Auth during production deployment? If not, what would be the recommended approach to ensure the @convex-dev/auth setup runs correctly for production? Thanks in advance for your help!
4 Replies
Convex Bot
Convex Bot7d 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!
erquhart
erquhart7d ago
You only need to run @convex-dev/auth --prod once from your local project to set it up No need to run it in CD
Rane
RaneOP7d ago
Oh, this explains it. Thank you so much! 😊 Is it considered best practice to include npx convex deploy in the build script?
"build": "tsc -b && vite build && npx convex deploy"
erquhart
erquhart7d ago
Best practice is something like npx convex deploy --cmd 'npm run build' You pass your build command to convex deploy, so if convex deploy fails your build doesn't run

Did you find this page helpful?