Deployment
Find answers to common web deployment issues.
Deployment build fails
This is most likely an issue related to the environment variables not being set correctly in the deployment environment. Please analyse the logs of the deployment provider to see what is the issue.
The kit is very defensive about incorrect environment variables, and will throw an error if any of the required environment variables are not set. In this way - the build will fail if the environment variables are not set correctly - instead of deploying a broken application.
Check our guides for the most popular hosting providers for more information on how to deploy your TurboStarter project correctly:
Vercel
Deploy your TurboStarter web app to Vercel platform.
Netlify
Deploy your TurboStarter web app to Netlify platform.
Render
Deploy your TurboStarter web app to Render platform.
Railway
Deploy your TurboStarter web app to Railway platform.
AWS Amplify
Deploy your TurboStarter web app to AWS Amplify platform.
Docker
Containerize your TurboStarter web app using Docker.
Fly.io
Deploy your TurboStarter web app to Fly.io platform.
What should I set as a URL before my first deployment?
That's very good question! For the first deployment you can set any URL, and then, after you (or your provider) assign a domain name, you can change it to the correct one. There's nothing wrong with redeploying your project multiple times.
Sign in with OAuth provider doesn't work
This is most likely a settings issues in the provider's settings. To troubleshoot this issue, follow these steps:
- Verify provider settings: Ensure that the OAuth provider's settings are correctly configured. Check that the client ID, client secret, and redirect URI are accurate and match the values in your application.
- Check environment variables: Confirm that the environment variables for the OAuth provider are set correctly in your application production environment.
- Validate callback URLs: Ensure that the callback URLs for each provider are set correctly and match the URLs in your application. This is crucial for the OAuth flow to work correctly.
Please read Better Auth documentation for more information on how to set up third-party providers.
Build runs out of memory
If the build fails with JavaScript heap out of memory:
Increase Node.js memory limit:
# In your build command
NODE_OPTIONS="--max-old-space-size=4096" pnpm buildFor Vercel, add to vercel.json:
{
"build": {
"env": {
"NODE_OPTIONS": "--max-old-space-size=4096"
}
}
}For other providers, set the NODE_OPTIONS environment variable in their dashboard.
Database connection issues in production
If you see "Connection refused" or "ECONNREFUSED" errors:
- Check DATABASE_URL is set correctly in your hosting provider
- Verify IP allowlist - many database providers require you to allowlist your deployment's IP addresses
- Check SSL requirements - production databases often require SSL:
DATABASE_URL="postgresql://...?sslmode=require"- Verify connection pooling - serverless environments may need connection pooling (e.g., PgBouncer, Neon's pooler)
CORS errors in production
If API requests fail with CORS errors:
- Verify
NEXT_PUBLIC_URLmatches your actual domain exactly (includinghttps://) - Check for trailing slashes -
https://example.comandhttps://example.com/are different origins - Verify API route is deployed - check
/api/statusis accessible
The API automatically configures CORS based on NEXT_PUBLIC_URL.
Preview deployments not working
If preview/staging deployments have issues:
- OAuth callbacks won't work unless you add preview URLs to your OAuth provider's allowed redirect URIs
- Webhooks need to point to the correct environment (use separate webhook endpoints for staging)
- Database - ensure preview uses a separate database or the same one as staging (not production)
How is this guide?
Last updated on