A typical layout:
| App | Domain |
|---|---|
| Storefront | yourstore.com |
| Admin | admin.yourstore.com |
| API | api.yourstore.com |
DNS
Add each domain in its host’s dashboard (Vercel Settings → Domains, Render Settings → Custom Domains, and so on). The host shows the record to create at your domain registrar, usually a CNAME to the host for a subdomain, or an A record for the root domain.
CORS
With NODE_ENV=production, the API only accepts browser requests from:
CLIENT_URLandADMIN_URLPRODUCTION_CLIENT_URLandPRODUCTION_ADMIN_URLlocalhost
Set them to the exact addresses in the browser bar: scheme and host, no trailing slash.
PRODUCTION_CLIENT_URL=https://yourstore.com
PRODUCTION_ADMIN_URL=https://admin.yourstore.com
Restart the API after changing them.
Everything else that needs the domains
- Storefront:
NEXT_PUBLIC_API_URL,NEXT_PUBLIC_SITE_URL - Admin:
VITE_NEXT_PUBLIC_API_URL - Firebase: add both domains to Authentication → Settings → Authorized domains
- Stripe: the webhook URL
https://api.yourstore.com/api/payments/webhook
Warning
If it works locally but the live site shows CORS errors, the production URLs don’t match the browser address exactly. https://www.yourstore.com and https://yourstore.com are different sites.
