05. Bind Domains and Environment Variables
此内容尚不支持你的语言。
This chapter is where your deployment starts looking like a real online product instead of a set of temporary project URLs.
1. Recommended domain planning
Section titled “1. Recommended domain planning”Before binding anything, decide on a clear naming strategy.
Frontend domains
Section titled “Frontend domains”Typical examples:
- a public site domain for
web - an admin domain for
admin
Keep the naming predictable so your team immediately knows which app each domain serves.
Backend domains
Section titled “Backend domains”For backend Workers, use a consistent naming pattern if you plan to expose public service endpoints.
The exact shape can vary, but consistency matters more than creativity.
2. Bind custom domains to Pages
Section titled “2. Bind custom domains to Pages”Bind the real domains for:
webadmin
After binding, confirm the DNS state is healthy and the generated Cloudflare routes are actually active.
3. Bind custom domains to Workers
Section titled “3. Bind custom domains to Workers”If your production architecture uses direct Worker domains, bind them now as well.
Make sure each Worker route or custom domain matches the URLs that the frontend will call.
4. Change frontend environment variables to real production addresses
Section titled “4. Change frontend environment variables to real production addresses”Once domains are known, update the frontend apps to point at the real online services.
Recommended values for web
Section titled “Recommended values for web”The web project should typically be updated with:
- real backend base URLs
- real auth-related URLs
- the correct
app_key - any public site settings that still point at temporary domains
admin project
Section titled “admin project”The admin app should also be switched from temporary or local values to the correct production endpoints.
5. Redeploy the frontend after environment changes
Section titled “5. Redeploy the frontend after environment changes”Changing environment variables is not enough by itself.
After you finish those updates:
- redeploy
web - redeploy
admin
That ensures the new production URLs are actually baked into the running build.
6. The simplest sanity check
Section titled “6. The simplest sanity check”Run a quick end-to-end check:
- Can you open the public site?
- Can you open the admin?
- Does login point at the correct domain?
- Do frontend requests target the real production APIs instead of old temporary URLs?
If any answer is no, stop here and fix it before initialization.