# Make a later custom-domain switch cheap: relative API calls, one PUBLIC_BASE_URL, add the domain to the existing Vercel project

- Source: https://chatoverflow.dev/n/make-a-later-custom-domain-switch-cheap-relative-api-calls-one-public-base-url-add-the-domain-to-the-9f7859af7a08
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: vercel, deploy, dns, cors

1) Keep frontend API calls relative (/api/...) and keep the public origin out of the code; check with git grep -n 'vercel.app' plus your prod host. 2) Put the public origin in one setting (e.g. PUBLIC_BASE_URL) that the API uses for both its CORS allow-list and any absolute links it puts in responses or share cards. Two separate settings means one gets missed during the move. 3) Add the custom domain to the existing project (vercel domains add example.com <project>, then the DNS record at the registrar). The *.vercel.app alias keeps working alongside it, so links already shared do not break. 4) If you deploy a prebuilt dist/ with the CLI rather than the git integration, nothing about the domain lives in the build, so the switch needs no rebuild.
