Adding a Custom Domain to Cloudflare Workers and Pages: Menu Instead of CNAME Records
In this article, we will discuss how to add a custom domain to Cloudflare Workers and Pages using the Workers and Pages menu instead of adding CNAME records. This approach provides a more streamlined and efficient way to manage your custom domains.
Prerequisites
Before we begin, make sure you have the following:
- A Cloudflare account
- A registered domain with Cloudflare
- A Workers site or a Pages site
Step 1: Access the Workers and Pages Dashboard
Log in to your Cloudflare account and navigate to the Workers tab. From there, click on the Pages tab to access the Workers and Pages dashboard.
Step 2: Create a New Site or Select an Existing Site
If you haven't already, create a new site by clicking the Create a Project button. If you have an existing site, select it from the list of projects.
Step 3: Add a Custom Domain
Once you have selected your site, click on the Settings tab and then click on the Custom Domains tab. Click the Add Custom Domain button and enter your custom domain.
Step 4: Configure DNS Records
After adding your custom domain, Cloudflare will provide you with the necessary DNS records to configure. Instead of adding CNAME records, you will add a TXT record for domain verification and an A record for routing traffic to Cloudflare Workers and Pages.
Step 5: Verify Domain Ownership
To verify domain ownership, follow the instructions provided by Cloudflare to add the TXT record to your domain registrar's DNS settings. Once the TXT record is added, click the Verify button in the Cloudflare dashboard.
Step 6: Route Traffic to Cloudflare Workers and Pages
To route traffic to Cloudflare Workers and Pages, add the A record provided by Cloudflare to your domain registrar's DNS settings. This record will point your custom domain to Cloudflare's IP addresses.
Step 7: Wait for Propagation
After adding the DNS records, wait for the changes to propagate. This process can take up to 24 hours.
Step 8: Test Your Custom Domain
Once the DNS records have propagated, test your custom domain by visiting it in a web browser. If everything is configured correctly, your Workers or Pages site should be accessible using your custom domain.
Adding a custom domain to Cloudflare Workers and Pages using the Workers and Pages menu instead of CNAME records provides a more streamlined and efficient way to manage your custom domains. By following the steps outlined in this article, you can easily add a custom domain to your Workers or Pages site and enjoy the benefits of using a custom domain.
References
// Example Workers script
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
return new Response('Hello, World!', {status: 200})
}