Overview
The deployment architecture includes:- Static Frontend: Vite-built React SPA served from
/dist - SPA Rewrites: Client-side routing handled by
vercel.jsonrewrites - Serverless Functions: API routes in
/api/*for media proxying, admin operations, and webhooks - Branch-Based Deployments: Strict two-lane flow (staging → production)
Vercel Configuration
Thevercel.json:1-90 file defines the build and routing configuration.
Build Settings
- Runs
npm run buildwhich executesscripts/build-site.mjs - Outputs to
dist/directory containing:dist/index.html- Auth shell for/dist/app/index.html- Main SPA entrydist/app/assets/*- Bundled JS, CSS, and assets
SPA Rewrites
All application routes rewrite to the SPA entry point for client-side routing:/- Root route (auth shell)/app- Main application/admin- Admin dashboard (requires admin role)/profile- User profile and settings/download- Landing page download interface/app/assets/*- Static assets (served directly)
Serverless Function Configuration
Certain API routes require extended timeouts for heavy operations:api/download-page.js- HTML page archival (120s timeout)api/admin/scrape.js- Admin scraping operations (60s)api/landing-ripper/*- Apify integration webhooks and downloads
Deployment Workflow
AdRecon uses a strict two-lane deployment flow to maintain environment consistency.Branch Strategy
The deployment script enforces branch requirements. Attempting to deploy from the wrong branch will fail with a clear error message.
| Environment | Branch | Command | Vercel Target |
|---|---|---|---|
| Staging | staging | npm run deploy:staging | Preview |
| Production | main | npm run deploy:production | Production |
Deploy to Staging
Run staging deploy
Execute the staging deployment script:This runs
scripts/deploy-vercel.sh:21-28 which:- Verifies you’re on the
stagingbranch - Runs
vercel deploy -yfor a preview deployment
Deploy to Production
Run production deploy
Execute the production deployment script:This runs
scripts/deploy-vercel.sh:31-37 which:- Verifies you’re on the
mainbranch - Runs
vercel deploy --prod -yfor a production deployment
Deployment Script Details
Thescripts/deploy-vercel.sh:1-38 script provides branch enforcement:
Branch Protection
The script prevents common deployment mistakes:- Cannot deploy to production from
stagingbranch - Cannot deploy to staging from
mainbranch - Clear error messages indicate which branch is required
Environment Variables
Configure environment variables in Vercel Dashboard:Add variables for each environment
Add all required variables from the Environment Variables page.Set the scope for each variable:
- Production: Used for
mainbranch deploys - Preview: Used for
stagingand other preview deploys - Development: Used for local
vercel devcommand
Required Variables
At minimum, configure these for production:Build Ignore Strategy
Thevercel.json:4 ignoreCommand prevents builds on non-protected branches:
staging and main branches.
Monitoring & Debugging
View Deployment Logs
- Go to Vercel Dashboard → Deployments
- Click on a deployment to view build logs
- Check “Functions” tab for serverless function logs
Common Issues
Build Failures:- Check build logs in Vercel dashboard
- Verify all environment variables are set
- Ensure
package.jsondependencies are up to date
- Check function logs in Vercel → Deployments → Functions
- Verify Supabase connection (check
SUPABASE_URLand keys) - Ensure Supabase RLS policies allow access
- Verify
vercel.jsonrewrites are correct - Check that SPA routes are handled by React Router
- Clear browser cache and test in incognito mode
Rollback Strategy
If a production deployment has issues:Identify last good deployment
Go to Vercel Dashboard → Deployments and find the last working deployment.
Promote previous deployment
Click the three dots (•••) next to the deployment → “Promote to Production”
Performance Optimization
Caching Strategy
Vercel automatically caches static assets indist/app/assets/*:
- JS bundles are cache-busted with content hashes
- CSS files include content hashes
- Images and fonts are cached indefinitely
Edge Network
Vercel deploys to a global edge network:- Static assets served from nearest edge location
- Serverless functions run in the optimal region
- Automatic DDoS protection and SSL
Next Steps
After deploying to Vercel:- Configure custom domain in Vercel → Settings → Domains
- Update Supabase redirect URLs to include production domain
- Set up monitoring with Vercel Analytics
- Configure alerts for function errors
- Review security headers in Vercel settings