Custom Domain Configuration
Overview​
In this module, you'll configure custom domains for both your BlazeNote frontend and backend applications. As outlined in our Getting Started guide, custom domains provide professional URLs for your serverless applications while maintaining the performance benefits of Cloudflare's global edge network.
Custom Domain Architecture:
- Frontend Domain:
blazenote-frontend.<your-domain>.<tld>→ Cloudflare Pages - Backend Domain:
blazenote-backend.<your-domain>.<tld>→ Cloudflare Workers - SSL/TLS: Automatic certificate provisioning and management
- DNS Management: Cloudflare-managed DNS with global propagation
- Performance: Edge-optimized routing with CDN benefits
This setup establishes production-ready domains for your note-taking application, enabling professional deployment with custom branding while leveraging Cloudflare's security and performance features.
Prerequisites​
Before starting, ensure you have:
- Cloudflare Account: Active account with access to dashboard
- Deployed Applications: Both frontend (Pages) and backend (Workers) successfully deployed
- Domain Access: Domain allocated through the workshop Enterprise zone
- DNS Understanding: Basic familiarity with DNS record types (CNAME, A records)
Workshop Participants: You have been provided with access to an Enterprise zone for this workshop. Your allocated domain will be available in your Cloudflare account dashboard under Account Home.
Steps​
1. Locate Your Allocated Domain​
First, find the domain that has been allocated to you for this workshop.
Access Account Dashboard​
- Log into your Cloudflare Dashboard
- Navigate to Account Home (main dashboard)
- Look for your allocated domain in the zones list

Identify Your Domain​
Your domain format will be:
- Pattern:
<your-assigned-subdomain>.sxplabs.com - Example:
intrepid-reactor.sxplab.com
Note down your domain: _______________________
Each workshop participant receives a unique subdomain within the Enterprise zone. This ensures isolated environments while providing full DNS control capabilities.
2. Configure Frontend Custom Domain (Pages)​
Set up a custom domain for your BlazeNote frontend application deployed on Cloudflare Pages.
Access Pages Project Settings​
- Navigate to Cloudflare Dashboard → Compute (Workers) → Workers & Pages
- Select the Pages tab
- Click on your blazenote-frontend project
- Go to Custom domains in the sidebar

Add Frontend Domain​
-
Click "Set up a custom domain"
-
Enter your domain:
blazenote-frontend.<your-domain>.<tld>
Example:
blazenote-frontend.intrepid-reactor.sxplab.com
- Click "Continue"

-
Click "Activate domain"

-
Now you wait for the domain to be validate and DNS propagation
-
At the same time, you may proceed to next steps
Verify Frontend Domain​
Wait for DNS propagation (2-5 minutes), then test:
# Test your frontend domain
curl -I https://blazenote-frontend.<your-domain>.<tld>
Expected response:
HTTP/2 200
server: cloudflare
content-type: text/html
...
Or visit in browser:
https://blazenote-frontend.<your-domain>.<tld>

3. Configure Backend Custom Domain (Workers)​
Set up a custom domain for your BlazeNote backend application deployed on Cloudflare Workers.
Access Workers Project Settings​
- Navigate to Cloudflare Dashboard → Compute (Workers) → Workers & Pages
- Select the Workers tab
- Click on your blazenote-backend project
- Go to Settings → Domains & Routes
Add Backend Domain​
1. Add Custom Domain:
- Click Add next to "Domains & Routes"
- Select Custom Domain
2. Enter your domain:
blazenote-backend.<your-domain>.<tld>
Example:
blazenote-backend.intrepid-reactor.sxplab.com
3. Click "Add Domain"

Configure via Wrangler to keep your local development environment in sync​
You can also configure custom domains through your wrangler.toml or wrangler.jsonc file as an alternative to the dashboard method.
Navigate to your backend project:
cd ~/projects/blazenote-backend
Update wrangler.toml:
name = "blazenote-backend"
main = "src/index.ts"
compatibility_date = "2024-12-30"
compatibility_flags = ["nodejs_compat"]
# Custom domain configuration
[[routes]]
pattern = "blazenote-backend.<your-domain>.<tld>"
custom_domain = true
# ... rest of your configuration
Or if using wrangler.jsonc:
{
"name": "blazenote-backend",
"main": "src/index.ts",
"compatibility_date": "2024-12-30",
"compatibility_flags": ["nodejs_compat"],
"routes": [
{
"pattern": "blazenote-backend.<your-domain>.<tld>",
"custom_domain": true
}
]
}
Deploy with updated configuration:
npm run deploy
Verify Backend Domain​
Test your backend domain:
# Test basic connectivity
curl https://blazenote-backend.<your-domain>.<tld>
# Test API endpoints
curl https://blazenote-backend.<your-domain>.<tld>/notes
Expected response:
Hello BlazeHack!
4. Update Application Configuration​
Update your applications to use the new custom domains for seamless integration.
Update Backend CORS Settings​
Edit your backend CORS configuration:
# Navigate to your backend project
cd ~/projects/blazenote-backend
Update src/index.ts:
// Define allowed origins
const allowedOrigins = new Set([
"http://localhost:5173", // Local development
"https://blazenote-frontend.<your-domain>.<tld>", // Your custom frontend domain
]);

Deploy the updated backend:
npm run deploy
Update Frontend Environment Variables​
Update your frontend environment variables to use the custom backend domain.
1. Access Frontend Environment Variables:
- Go to Cloudflare Dashboard → Workers & Pages
- Select your
blazenote-frontendproject - Click Settings tab
- Navigate to Environment variables
2. Update the Backend URL Variable:
Find the existing variable:
- Variable Name:
VITE_API_BASE_URL - Current Value:
https://blazenote-backend.<your-subdomain>.workers.dev
Update to new custom domain:
- Variable Name:
VITE_API_BASE_URL - New Value:
https://blazenote-backend.<your-domain>.<tld>
Example:
# Old value
VITE_API_BASE_URL=https://blazenote-backend.<tld>>.workers.dev
# New value with custom domain
VITE_API_BASE_URL=https://blazenote-backend.<your-subdomain>.sxplab.com
##Example
VITE_API_BASE_URL=https://blazenote-backend.intrepid-reactor.sxplab.com

3. Trigger Frontend Redeploy:
You must redeploy after updating environment variables. The build process needs to include the new backend URL.
To redeploy:
- Go to Deployments tab in your frontend project
- Find your latest deployment
- Click View details
- Click Retry deployment
4. For Local Development (Optional):
Update your local .env file:
cd ~/projects/blazenote-frontend
Use vi or nano to edit .env:
# Update for custom domain development
VITE_API_BASE_URL=https://blazenote-backend.<your-domain>.<tld>
# Optional: Keep local backend for development
# VITE_API_BASE_URL=http://localhost:8787
Domain Summary​
After completing this module, you'll have the following custom domains configured:
Frontend Application​
- URL:
https://blazenote-frontend.<your-domain>.<tld> - Service: Cloudflare Pages
Backend Application​
- URL:
https://blazenote-backend.<your-domain>.<tld> - Service: Cloudflare Workers
Integration​
- CORS: Frontend domain whitelisted in backend
- API Calls: Frontend configured to use custom backend domain
- Security: Full SSL/TLS encryption between all services
Validation Checklist​
Domain Configuration​
- Frontend custom domain accessible and loading correctly
- Backend custom domain responding to API calls
- DNS records properly configured and propagated
- SSL/TLS certificates active and valid
- Both domains showing "Proxied" status in DNS
Application Integration​
- Frontend environment variables updated with custom backend domain
- Frontend redeployed after environment variable changes
- Frontend successfully making API calls to custom backend domain
- CORS configured correctly (no console errors)
- All application features working with custom domains
- Performance optimization features enabled
Security Settings​
- SSL/TLS encryption mode set to "Full (strict)"
- HSTS enabled for both domains
- Security headers configured appropriately
- Auto HTTPS redirect active
Troubleshooting Guide​
Common DNS Issues​
"This site can't be reached" errors
# Check DNS propagation
nslookup blazenote-frontend.<your-domain>.<tld>
nslookup blazenote-backend.<your-domain>.<tld>
Solution:
- Wait 5-10 minutes for DNS propagation
- Verify CNAME records are correctly configured
- Ensure proxy status is enabled (orange cloud)
SSL Certificate errors
# Check SSL certificate status
curl -I https://blazenote-frontend.<your-domain>.<tld>
Solution:
- Wait for certificate provisioning (can take up to 15 minutes)
- Verify DNS records are proxied through Cloudflare
- Check SSL/TLS encryption mode is set to "Full (strict)"
Common Integration Issues​
CORS errors in browser console
// Error: "blocked by CORS policy"
Solution:
- Update backend CORS configuration in
src/index.ts - Ensure frontend domain is included in
allowedOrigins - Redeploy backend after CORS changes
API calls failing from frontend
// Error: "Failed to fetch" or network errors
Solution:
- Check frontend environment variables - ensure
VITE_API_BASE_URLuses custom domain - Redeploy frontend after updating environment variables
- Verify backend custom domain is accessible
- Check frontend API base URL configuration
- Ensure both domains are using HTTPS
Mixed content warnings
// Warning: "Mixed Content" in browser console
Solution:
- Ensure all API calls use HTTPS
- Verify SSL/TLS is properly configured
- Check for any HTTP resources in HTTPS pages
Best Practices​
Security Recommendations​
- Always use HTTPS: Ensure all communications are encrypted
- Strict SSL/TLS: Use "Full (strict)" mode for maximum security
- HSTS Headers: Enable HTTP Strict Transport Security
- Regular Updates: Keep applications and dependencies updated
Performance Optimization​
- CDN Benefits: Leverage Cloudflare's global CDN
- Compression: Enable Brotli and Gzip compression
- Caching: Configure appropriate cache rules
- Minification: Enable automatic minification for web assets
Maintenance​
- Monitor Certificates: Set up alerts for certificate expiration
- DNS Health: Regularly verify DNS record integrity
- Performance Metrics: Use Cloudflare Analytics for insights
- Security Monitoring: Enable security events monitoring
Next Steps​
🎉 Congratulations! You've successfully configured custom domains for your BlazeNote application.
What you've accomplished:
- Professional custom domains for both frontend and backend
- Automatic SSL/TLS certificate provisioning
- Optimized DNS configuration with CDN benefits
- Secure application integration with proper CORS settings
Next up:
- Database Setup: Initialize D1 database with required schemas
- File Storage Configuration: Set up R2 buckets for file uploads
- Production Testing: Comprehensive testing of all application features
- Monitoring Setup: Configure analytics and performance monitoring
Your custom domains are now ready to serve:
- Professional URLs: Branded domains for your note-taking application
- SSL/TLS Security: Automatic certificate management and renewal
- Global Performance: Edge-optimized delivery worldwide
- Scalable Architecture: Production-ready serverless infrastructure