Common issues and solutions for the AI Starter Kit.
Solution:
# Clear cache
pnpm store prune
# Try again
pnpm install --force
# Or use npm
npm installSolution:
# Check version
node --version # Should be 18.x+
# Install correct version
nvm install 20
nvm use 20Solution:
# Run Convex dev first
npx convex dev
# Then generate types
npx convex codegenSolution:
- Check internet connection
- Verify you're logged in:
npx convex dev - Check port 3210 isn't in use
- Try:
npx convex dev --onceto test connection
Solution:
# Verify environment variables
npx convex env list
# Should see:
# BETTER_AUTH_SECRET
# SITE_URLSolution:
# Regenerate after schema changes
npx convex codegen
# Restart Convex devSymptoms:
- Repeated 500 errors in the terminal:
GET /api/auth/get-session 500 in 10.6s - Auth pages hang or fail to load
- Signup/login doesn't work
Cause: NEXT_PUBLIC_CONVEX_SITE_URL is set to http://localhost:3000 instead of your Convex HTTP endpoint, causing an infinite loop.
Explanation: The Next.js auth handler at app/api/auth/[...all]/route.ts proxies auth requests to Convex. When NEXT_PUBLIC_CONVEX_SITE_URL is set to localhost:3000, it proxies back to itself, creating an infinite loop until timeout.
Solution:
- Open
.env.local - Find or add
NEXT_PUBLIC_CONVEX_SITE_URL - Set it to your Convex site URL:
# WRONG - causes infinite loop: NEXT_PUBLIC_CONVEX_SITE_URL=http://localhost:3000 # CORRECT - use your Convex HTTP endpoint: NEXT_PUBLIC_CONVEX_SITE_URL=https://your-deployment.convex.site
- The deployment name should match
NEXT_PUBLIC_CONVEX_URLbut with.siteinstead of.cloud - Restart your dev server
Checklist:
-
BETTER_AUTH_SECRETis set -
SITE_URLmatches your dev URL -
NEXT_PUBLIC_CONVEX_SITE_URLends in.convex.site(NOTlocalhost:3000) - Convex dev is running
- No browser console errors
Solution:
# Verify environment variables
npx convex env list
# Restart Convex dev
npx convex devSolution:
Check SITE_URL matches exactly:
npx convex env set SITE_URL http://localhost:3000
# NOT https, NOT trailing slashSolution:
- Clear browser cookies
- Check session duration in
convex/auth.config.ts - Re-login
Solution:
# Run services separately to debug
pnpm run dev:backend # Terminal 1
pnpm run dev:frontend # Terminal 2Solution:
# Use different port
pnpm run dev:frontend -- -p 3001
# Update SITE_URL
npx convex env set SITE_URL http://localhost:3001Solution:
- Restart dev server
- Clear
.nextcache:rm -rf .next - Check file changes are saving
Solution:
# Regenerate types
npx convex codegen
# Restart TypeScript server in VS Code:
# Cmd+Shift+P → "TypeScript: Restart TS Server"Solution:
npx convex codegen
pnpm run testSolution:
Check convex/test.setup.ts exists and contains:
import { modules } from "convex-test/test.setup.js";
export { modules };Solution:
- Increase Vitest timeout in
vitest.config.ts - Check Convex functions aren't calling external APIs
- Simplify test to isolate issue
Solution:
- Check build logs for specific error
- Try building locally:
pnpm run build - Ensure all dependencies are in
dependencies(notdevDependencies) - Check
NEXT_PUBLIC_CONVEX_URLis set in Vercel
Solution:
# Verify production env vars
npx convex env list --prod
# Update SITE_URL to production domain
npx convex env set SITE_URL https://yourdomain.com --prodSolution:
- Check Convex dashboard logs:
npx convex dashboard --prod - Verify Convex deployment:
npx convex deploy - Check browser console for errors
- Verify
NEXT_PUBLIC_CONVEX_URLmatches production URL
Solution:
Add indexes in convex/schema.ts:
.index("by_userId", ["userId"])Solution:
- Use dynamic imports for large components
- Check for duplicate dependencies
- Analyze bundle:
pnpm run build && npx @next/bundle-analyzer
Cause: Function name typo or not exported
Solution: Check function name matches in api.myModule.functionName
Cause: Argument type mismatch
Solution: Check validator definitions match your data types
Cause: Wrong SITE_URL configuration
Solution:
npx convex env set SITE_URL http://localhost:3000- Check Convex Documentation
- Check Better Auth Documentation
- Open an issue: GitHub Issues
- Review existing issues for similar problems
When something isn't working:
- Check browser console for errors
- Check terminal for error logs
- Verify environment variables
- Restart dev servers
- Clear cache (
.next, browser cache) - Run
npx convex codegen - Check Convex dashboard for logs
Previous: ← Authentication | Next: IDE Tools →