www/apps/cloud/app/environments/custom-domains/page.mdx
import { Note, InlineIcon, CodeTab, CodeTabs } from "docs-ui" import { EllipsisHorizontal } from "@medusajs/icons"
export const metadata = {
title: Environment Custom Domains,
}
In this guide, you'll learn how to set up custom domains for your backend and storefront deployed on Cloud.
By default, Medusa environments are deployed with medusajs.app (backend) and medusajs.site (storefront) subdomains. You can configure custom domains to use your own branded URLs for both your backend and storefront.
To update the default medusajs.app and medusajs.site subdomains instead, see the Update Subdomains guide.
You can configure custom domains per environment, allowing you to use different domains for Production, Staging, and preview environments based on your needs.
Backend custom domains allow you to serve your Medusa backend from your own domain instead of the default medusajs.app subdomain.
Backend custom domains are available for Scale and Enterprise plans only. Learn more about plan features on the pricing page.
</Note>To set up a backend custom domain, you need:
To set up a backend custom domain:
api.acme.com)You can track your domain's setup progress with the Domain Status Indicators.
To avoid downtime in you storefront while DNS changes propagate for your backend's custom domain, Medusa doesn't update the backend URL set in the storefront automatically. The storefront will still point to the backend's original subdomain.
Once you've verified that DNS changes have propagated and the custom domain is correctly pointing to the Medusa backend, you need to manually update the backend URL in your storefront's configuration to point to the new custom domain.
Based on your storefront framework, update the backend environment variable:
<CodeTabs group="storefront-framework"> <CodeTab label="Next.js" value="nextjs">NEXT_PUBLIC_MEDUSA_BACKEND_URL= # Your Medusa backend's URL
# Update any other envionment variable that uses the Medusa backend URL
# For example:
MEDUSA_BACKEND_URL= # Your Medusa backend's URL
VITE_MEDUSA_BACKEND_URL= # Your Medusa backend's URL
# Update any other envionment variable that uses the Medusa backend URL
# For example:
MEDUSA_BACKEND_URL= # Your Medusa backend's URL
To learn how to update environment variables on Cloud, see the Environment Variables guide.
After updating the backend URL, redeploy your environment. Your live storefront will now connect to your Medusa backend through the new custom domain without any downtime.
Storefront custom domains allow you to serve your storefront from your own domain instead of the default medusajs.site subdomain.
Storefront custom domains are available for Launch, Scale, and Enterprise plans only. Learn more about plan features on the pricing page.
</Note>To set up a storefront custom domain, you need:
If no custom domain is configured for your storefront environment, you'll see a Setup Custom Domain link in the environment card:
shop.acme.com)You can track your domain's setup progress with the Domain Status Indicators.
After adding a custom domain, you'll see a status below the domain name that help you track the setup progress:
Domain activation typically completes within a few minutes to 48 hours, depending on DNS propagation times.
Removing a custom domain will immediately stop serving traffic from that domain. Make sure to update any integrations or client applications before removing a domain.
</Note>To remove a custom domain:
If your domain remains in Pending or Configured status:
If your storefront isn't connecting to the backend after setting up a backend custom domain, make sure you updated the backend URL in your storefront's environment variables and redeployed your environment.