3.4 KiB
3.4 KiB
Production Deployment - n8n Webhook Routing
Prerequisites
Ensure your production environment has:
docker-compose.ymlanddocker-compose.local.ymlupdated with new n8n webhook routingsupabase/kong.ymlupdated with n8n webhook servicefrontend/admin.jsupdated with new sendOrderEmailDirect function- Production domain configured (e.g.,
your-domain.com)
Deployment Steps
1. Update Production Config
Edit frontend/config.js and replace localhost:55521 with your production domain:
window.MCCARS_CONFIG={
SUPABASE_URL:"https://your-domain.com",
SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
N8N_WEBHOOK_URL:"https://your-domain.com/webhook/manual-email-send"
};
Replace:
your-domain.comwith your actual production domain- Keep the same ANON_KEY value
2. Optional: Configure WEBHOOK_DOMAIN
If you want n8n to know its public webhook URL (for n8n UI display), set environment variable:
export WEBHOOK_DOMAIN=https://your-domain.com
This tells n8n that webhooks are accessible at https://your-domain.com/webhook/* from the internet.
3. Deploy Updated Files
Push these files to production:
supabase/kong.yml(updated with n8n webhook service)docker-compose.yml(updated WEBHOOK_URL variable syntax)frontend/config.js(updated with production domain)frontend/admin.js(updated sendOrderEmailDirect function)
4. Restart Stack on Production Server
# On production host
cd /mnt/user/appdata/mc-cars # or your deployment path
# Pull latest code
git pull origin dev # or your deployment branch
# Restart with new config
docker-compose down
docker-compose up -d --build
# Verify services are healthy
docker-compose ps
5. Verify Webhook Routing
Test webhook from production domain:
curl 'https://your-domain.com/webhook/manual-email-send' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'sales_order_id=YOUR_ORDER_ID'
Expected response: 200 OK with n8n workflow result
Network Setup
Kong must be accessible from the internet:
- Port 55521 exposed via reverse proxy (nginx/Apache) or firewall rule
- Domain DNS points to production server
- SSL certificate configured (recommended to use Kong's 8443 port with cert)
Troubleshooting
"Failed to fetch" on send email button
-
Check Kong is routing webhook:
docker-compose exec kong curl -v http://n8n:5678/webhook/manual-email-send -
Verify Kong config loaded:
docker-compose logs kong | grep "n8n-webhooks" -
Check n8n workflow is active:
docker-compose logs n8n | grep "webhook"
CORS errors
Ensure Kong's CORS plugin is enabled for /webhook/ routes (should be in kong.yml):
plugins:
- name: cors
Webhook not triggering from browser
Verify in browser DevTools:
- Network tab shows POST to
/webhook/manual-email-send - Response status is 200 (not 404 or 500)
- Check n8n logs for workflow execution
Rollback
If issues occur:
# Rollback config.js to localhost for debugging
git checkout frontend/config.js
docker-compose up -d
# Then fix and redeploy
Verification Checklist
- Kong routing
/webhook/*to n8n ✓ - Frontend config.js has production domain ✓
- Admin portal can reach Kong on correct port ✓
- Webhook accepts POST requests ✓
- n8n workflow triggers and sends email ✓
- Email appears in order record ✓