Important: ALL logged-out users ALWAYS use production data regardless of environment. This includes landing page, auth pages, and any logged-out interactions. See LANDING_PAGE_PRODUCTION_DATA.md for details.
| Environment | URL | Data | Stripe | Collections |
|---|---|---|---|---|
| Local (main branch) | localhost:3000 |
Prod | Live | No prefix |
| Local (dev branch) | localhost:3000 |
Dev | Test | DEV_* |
| Local (other branches) | localhost:3000 |
Dev | Test | DEV_* |
| Dev Deploy | dev-wewrite.vercel.app |
Dev | Test | DEV_* |
| Preview | preview-wewrite.vercel.app |
Prod | Live | No prefix |
| Production | wewrite.app |
Prod | Live | No prefix |
# Via API
curl https://your-deployment.vercel.app/api/debug/environment
# Via Test Script
cd app && npx tsx scripts/test-environment-config.ts- Development (dev branch, other branches): Should see
DEV_subscriptions,DEV_users, etc. - Production (main branch, preview, production): Should see
subscriptions,users, etc.
- Development: Keys start with
sk_test_andpk_test_ - Production/Preview: Keys start with
sk_live_andpk_live_
cd app
npx tsx scripts/test-environment-config.ts# Local development
echo $NODE_ENV $SUBSCRIPTION_ENV
# In deployment
curl https://your-app.vercel.app/api/debug/environment# Deploy dev branch (triggers dual deployment)
git push origin dev
# Deploy to production
git push origin main- Main branch: Uses production collections - CAUTION: Real data!
- Dev branch: Uses
DEV_collections - Safe for testing - Other branches: Uses
DEV_collections - Safe for testing - Safe to test payments with appropriate Stripe keys based on branch
- Push to
devbranch - Check both environments:
dev-wewrite.vercel.app(dev data)preview-wewrite.vercel.app(prod data)
- Merge
dev→main - Automatic production deployment
- Test payments in development environments
- Modify dev collections
- Experiment with features locally
- Testing in preview environment (uses prod data)
- Modifying subscription logic
- Payment webhook changes
- Test with live Stripe keys in development
- Modify production collections directly
- Deploy untested code to main branch
NODE_ENV=development
SUBSCRIPTION_ENV=development
STRIPE_SECRET_KEY=sk_test_...
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...NODE_ENV=development
SUBSCRIPTION_ENV=development
VERCEL_ENV=developmentNODE_ENV=production
SUBSCRIPTION_ENV=production
VERCEL_ENV=previewNODE_ENV=production
SUBSCRIPTION_ENV=production
VERCEL_ENV=production- Check environment detection:
/api/debug/environment - Verify
SUBSCRIPTION_ENVvariable - Run test suite to validate configuration
- Verify key format (
sk_test_vssk_live_) - Check webhook endpoints match environment
- Confirm publishable key matches secret key
- Check if using correct collection prefix
- Verify Firebase permissions
- Check environment variable configuration
- Use
http://localhost:3000or your local IP - Test with Stripe test cards
- Safe to test all payment flows
- Use
https://preview-wewrite.vercel.app - Caution: Uses real production data
- Test with small amounts or test accounts
- Branch-Aware Development Guide - 🆕 Detailed branch-based workflow
- Full Environment Architecture
- Dual Deployment Setup
- Subscription System Docs
- Environment Test Suite
- Run the test suite first
- Check the debug endpoint
- Review environment variable configuration
- Consult the full architecture documentation