This script (production-setup.ts) sets up your Medusa production environment to match your localhost configuration exactly.
The script automatically configures:
- ✅ Store Configuration - Sets up currencies (AED, USD, EUR)
- ✅ UAE Region - Creates region with AED currency
- ✅ Stock Location - UAE Warehouse in Sharjah
- ✅ Sales Channels - Default sales channel
- ✅ Shipping Profiles - Default shipping profile
- ✅ Service Zones - UAE and GCC Countries zones
- ✅ Shipping Options - With prices already attached:
- UAE Standard: AED 15.00 (2-3 days)
- UAE Express: AED 25.00 (Next day)
- GCC International: AED 50.00 (5-7 days)
- ✅ Tax Regions - UAE tax configuration
Note: Admin user creation should be done separately using npm run create-admin
Ensure these environment variables are set on your production server:
# Required
ADMIN_EMAIL=your-admin@example.com
ADMIN_PASSWORD=your-secure-password
DATABASE_URL=postgresql://user:pass@host:5432/dbname
REDIS_URL=redis://host:6379
STRIPE_API_KEY=sk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...
# Recommended
MEDUSA_BACKEND_URL=https://your-backend-domain.com
JWT_SECRET=your-production-jwt-secret-min-32-chars
COOKIE_SECRET=your-production-cookie-secret-min-32-chars# Navigate to your app directory
cd /app
# Step 1: Create admin user (if not already created)
npm run create-admin
# Step 2: Run the production setup
npm run production-setupcd false
# Step 1: Create admin user (if not already created)
pnpm run create-admin
# Step 2: Run the production setup
pnpm run production-setup━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 MEDUSA PRODUCTION SETUP
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
👤 Step 1: Checking admin user...
✓ Admin user already exists: admin@example.com
🏪 Step 2: Configuring store...
✓ Store currencies configured (AED default)
📺 Step 3: Setting up sales channel...
✓ Created Default Sales Channel
🇦🇪 Step 4: Setting up UAE region...
✓ Created UAE region (AED)
✓ Created tax region for UAE
📦 Step 5: Setting up stock location...
✓ Created stock location: UAE Warehouse - Sharjah
🚚 Step 6: Setting up shipping profiles...
✓ Created Default Shipping Profile
🌍 Step 7: Setting up fulfillment sets and service zones...
✓ Created fulfillment set: UAE & GCC Shipping
✓ Created service zone: UAE
✓ Created service zone: GCC Countries
💰 Step 8: Setting up shipping options with prices...
✓ Created 3 shipping options with prices
🔗 Step 9: Linking sales channel to stock location...
✓ Linked Default Sales Channel to stock location
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ PRODUCTION SETUP COMPLETE!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- Verify Admin Panel: Visit
https://your-backend-url/appand login - Check Shipping Options: Go to Settings → Locations & Shipping
- Test Order Creation: Place a test order from your frontend
- Restart Backend: In Coolify, restart your Medusa service
This is normal - the script skips existing resources. It will only create what's missing.
Make sure you've restarted the backend after running the script.
- Check backend logs for specific errors
- Verify Stripe webhook is configured correctly
- Ensure STRIPE_API_KEY and STRIPE_WEBHOOK_SECRET are set
This script is safe to run multiple times:
- ✅ Won't create duplicate resources
- ✅ Reuses existing configurations
- ✅ Only creates missing items
- ✅ No data loss
To verify your production matches localhost:
# Localhost
cd false
pnpm run dev
# Visit http://localhost:9000/app
# Production
# Visit https://your-backend-url/appBoth should now have:
- Same admin credentials
- Same regions (UAE with AED)
- Same shipping options with prices
- Same store configuration
pnpm run create-admin- Create/update admin user onlypnpm run setup-shipping- Setup shipping only (without prices)pnpm run add-shipping-prices- Add prices to existing shipping optionspnpm run seed- Seed demo products (Europe-focused)
- The script creates UAE-focused configuration (not European like the seed script)
- Shipping prices are in cents (1500 = AED 15.00)
- GCC countries include: Saudi Arabia, Kuwait, Bahrain, Qatar, Oman
- Payment provider must be configured separately in Admin UI