Serve an external website under a specific path

Hi,
We want to launch our blog (not on Bubble) on a domain path like domain.com/blog. Our website is hosted behind Cloudflare, and since we’ve set our main domain on the Bubble app, we’re trying to handle it using workers. This solution works for other domains and services, but not Bubble. We’re facing a 404 error when we try to visit the above path. Is there a straightforward solution to this issue?

I couldn’t find any solution neither in the forum nor the official docs.

When using Cloudflare Workers to proxy requests to your blog, make sure that your worker is correctly routing requests to the /blog path and not interfering with Bubble’s routing. You might need to check the worker script to ensure it handles that specific path properly.

Thanks for your suggestion. Here’s my worker code:

addEventListener(“fetch”, (event) => {
  event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
  // Get the URL of the incoming request
  const url = new URL(request.url);

  // Check if the path starts with “/blog”
  if (url.pathname.startsWith(“/blog”)) {
    // Redirect to the blog subdomain
    const redirectUrl = `https://blog.domain.com${url.pathname.replace(“/blog”, “”)}`;
    return Response.redirect(redirectUrl, 301); // Use 301 for permanent redirect
  }

  // If the path doesn’t match “/blog”, proceed with the normal request
  return fetch(request);
}

And here’s the worker route condition:
*domain.com/blog*

However, I still encounter the bubble 404 error page.

Have you tried the Bubble redirect settings?

It doesn’t align with our scenario. We want to deliver the blog to the end users behind the /blog path, not show them domain.com/blog at the first touchpoint and redirect them to blog.domain.com.

Your DNS is managed by Bubble when you connect via an A Record and your Cloudflare Workers or Rules don’t apply because the traffic isn’t proxied trough your CF account but Bubble’s.

For this to work, you have to remove the A Records to Bubble and point to bubble via a CNAME → app.bubble.io.

Then the traffic will be proxied trough your Cloudflare account and it will respect Workers and Rules.

Thanks, it works, but it appears that Bubble recognizes the DNS records as invalid and has disabled certain features, such as the preview with the configured domain.