Cloudflare Workers
Use Cloudflare Workers to serve your blog at a subpath like yoursite.com/blog. Workers intercept requests and route them to the appropriate destination based on the URL path.
You'll need a Cloudflare account and a domain (either managed on Cloudflare or elsewhere). If using Cloudflare for DNS, consider disabling proxying for CNAME records to avoid configuration conflicts.
Create a Cloudflare Worker
If you don't already have a Worker, create one through the Cloudflare dashboard:
- Log into your Cloudflare dashboard
- Navigate to Workers & Pages
- Click Create Worker
- Give your Worker a descriptive name
- Click Deploy to create the initial Worker
For detailed steps, see Cloudflare's Workers getting started guide.
Configure the Worker Script
Edit your Worker's code to route Waldium paths to your Waldium site. Replace [SUBDOMAIN] with your Waldium subdomain and [YOUR_DOMAIN] with your website's domain.
Paths routed to Waldium:
/blog— Your blog content/waldium-assets— Static assets for your blog/_waldium— Internal Waldium resources/api/waldium-request— Waldium API endpoint
addEventListener("fetch", (event) => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
try {
const url = new URL(request.url);
// Route Waldium paths to Waldium
if (
url.pathname.startsWith("/blog") ||
url.pathname.startsWith("/waldium-assets") ||
url.pathname.startsWith("/_waldium") ||
url.pathname === "/api/waldium-request"
) {
const BLOG_URL = "[SUBDOMAIN].waldium.app";
const CUSTOM_URL = "[YOUR_DOMAIN]";
let proxyUrl = new URL(url.pathname + url.search, `https://${BLOG_URL}`);
let proxyRequest = new Request(proxyUrl, request);
proxyRequest.headers.set("Host", BLOG_URL);
proxyRequest.headers.set("X-Forwarded-Host", CUSTOM_URL);
proxyRequest.headers.set("X-Forwarded-Proto", "https");
proxyRequest.headers.set("CF-Connecting-IP", request.headers.get("CF-Connecting-IP"));
return await fetch(proxyRequest);
}
// Everything else passes through to origin
return await fetch(request);
} catch (error) {
return await fetch(request);
}
}
Click Deploy after adding the script.
Vercel Integration Considerations
If your main site is deployed on Vercel, the Worker must allow certain paths for domain verification and SSL certificates:
Required path allowlist:
/.well-known/acme-challenge/*— Let's Encrypt certificate verification/.well-known/vercel/*— Vercel domain verification
The script above passes all non-Waldium paths (including .well-known) through to your origin, so verification paths will work automatically. Ensure no additional rules block these paths.
Header forwarding:
The Host header must be correctly set in the Worker. The example script handles this, but custom modifications could break verification.
Webflow and Other Site Builders
If your main site runs on Webflow or another platform, you'll need the Worker to handle all traffic—routing blog requests to Waldium and everything else to your main site.
Ensure your main site is accessible before deploying this Worker, or visitors will see errors.
- Set up a staging URL for your main site (e.g.,
landing.yoursite.com) - Update the Worker to route non-blog traffic to your staging URL:
addEventListener("fetch", (event) => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
try {
const url = new URL(request.url);
// Route Waldium paths to Waldium
if (
url.pathname.startsWith("/blog") ||
url.pathname.startsWith("/waldium-assets") ||
url.pathname.startsWith("/_waldium") ||
url.pathname === "/api/waldium-request"
) {
const BLOG_URL = "[SUBDOMAIN].waldium.app";
const CUSTOM_URL = "[YOUR_DOMAIN]";
let proxyUrl = new URL(url.pathname + url.search, `https://${BLOG_URL}`);
let proxyRequest = new Request(proxyUrl, request);
proxyRequest.headers.set("Host", BLOG_URL);
proxyRequest.headers.set("X-Forwarded-Host", CUSTOM_URL);
proxyRequest.headers.set("X-Forwarded-Proto", "https");
proxyRequest.headers.set("CF-Connecting-IP", request.headers.get("CF-Connecting-IP"));
return await fetch(proxyRequest);
}
// Route everything else to your main site
const MAIN_SITE_URL = "[LANDING_DOMAIN]";
let mainSiteUrl = new URL(url.pathname + url.search, `https://${MAIN_SITE_URL}`);
return await fetch(mainSiteUrl, {
method: request.method,
headers: request.headers,
body: request.body
});
} catch (error) {
return await fetch(request);
}
}
Replace [LANDING_DOMAIN] with your staging URL (e.g., landing.yoursite.com).
Add Your Custom Domain
After the Worker is deployed and tested, connect it to your domain:
- In Cloudflare, navigate to your Worker
- Go to Settings > Domains & Routes > Add > Custom Domain
- Enter your domain (e.g.,
yoursite.com)
Add both yoursite.com and www.yoursite.com for complete coverage.
If your domain already has DNS records pointing elsewhere, you'll need to remove them first. The Worker must control all traffic for your domain.
Test Your Setup
Before going live, verify the Worker routes correctly:
- Test the Worker preview URL — Visit
your-worker.your-subdomain.workers.dev/blog - Confirm blog content loads — You should see your Waldium blog
- Check your main site — Ensure non-blog pages still work
DNS Propagation
After configuring your domain, changes typically appear within a few minutes. However, DNS propagation can take 1-4 hours, and occasionally up to 48 hours. If your subpath isn't working immediately, wait before troubleshooting.