Set up an apex domain in Azure Static Web Apps
Domain names without a subdomain are known as apex or root domains. For example, the domain www.example.com
is the www
subdomain joined with the example.com
apex domain.
Some domain registrars (like Google and GoDaddy) don't allow you to point the apex domain to an existing URL. If your registrar doesn't support ALIAS
or ANAME
records, or doesn't allow CNAME
flattening, then you can't point your apex domain to the generated URL for your static web app.
If your registrar doesn't allow you to redirect the apex domain, consider the following options:
- Configure your domain with Azure DNS
- Forward the apex domain to the
www
subdomain
This guide demonstrates two options for configuring an apex domain.
Use the steps to set up with an ALIAS record if your domain registrar supports the
ALIAS
DNS record.If your registrar doesn't support
ALIAS
records, but does supportANAME
records orCNAME
flattening, see their documentation for configuration settings.Use the steps in forward to www subdomain if your domain registrar doesn't support the
ALIAS
DNS record.
Set up with an ALIAS record
Before you create the ALIAS
record, you first need to validate that you own the domain.
Validate ownership
Open the Azure portal.
Go to your static web app.
From the Overview window, copy the generated URL of your site and set it aside in a text editor for future use.
Under Settings, select Custom domains.
Select + Add.
In the Enter domain tab, enter your apex domain name.
For instance, if your domain name is
example.com
, enterexample.com
into this box (without any subdomains).Select Next.
In the Validate + Configure tab, enter the following values.
Setting Value Domain name This value should match the domain name you entered in the previous step. Hostname record type Select TXT. Select Generate code.
Wait as the code is generated. It make take a minute or so to complete.
Once the
TXT
record value is generated, copy (next to the generated value) the code to the clipboard.Select Close.
Open a new browser tab and sign in to your domain registrar account.
Go to your domain name's DNS configuration settings.
Add a new
TXT
record with the following values.Setting Value Type TXT
Host Enter @ Value Paste the generated code value you copied from the Azure portal. TTL (if applicable) Leave as default value. Save changes to your DNS record.
Set up an ALIAS record
Return to your domain name's DNS configuration settings.
Add a new
ALIAS
record with the following values.Setting Value Type ALIAS
Host Enter @ Value Paste the generated URL you copied from the Azure portal. Make sure to remove the https://
prefix from your URL.TTL (if applicable) Leave as default value. Save changes to your DNS record.
Since DNS settings need to propagate, this process can take some time to complete.
Open a new browser tab and go to your apex domain.
After the DNS records are updated, you should see your static web app in the browser. Also, inspect the location to verify that your site is served securely using
https
.
Forward to www subdomain
Each domain registrar has a different process for managing domain names. Once you sign in to your account with your registrar, look for domain forwarding options. Some registrars have this functionality listed under DNS options, while others have them associated with Website options.
Make sure as you set up forwarding that you only configure the apex domain to forward to the www
subdomain.
See your registrar's documentation for details.
Next steps
Feedback
Submit and view feedback for