EarlySEO Docs

Cloudflare Worker Setup

Host EarlySEO "Free Tools" on a subfolder of your main domain using Cloudflare Workers.

Open .mdx

Goal

Serve tools under a subpath like:

  • https://example.com/tools/*

while the actual tool app might live on a different origin.

High-level steps

  1. Create a Worker in Cloudflare Workers dashboard
  2. Add a route like example.com/tools/*
  3. In the Worker, proxy requests to the tools origin
  4. Set caching/headers as needed
  5. Test end-to-end (including assets, API calls, and client-side routing)

Example Worker (proxy)

Replace TOOLS_ORIGIN with the upstream host that serves your tool app.

export default {
  async fetch(request) {
    const url = new URL(request.url);

    // strip "/tools" prefix
    url.pathname = url.pathname.replace(/^\/tools/, '') || '/';

    const upstream = new URL(`https://TOOLS_ORIGIN${url.pathname}${url.search}`);
    const resp = await fetch(upstream.toString(), request);

    // You may want to add caching headers here
    return resp;
  },
};

Gotchas

  • If the upstream app uses absolute URLs, you may need to rewrite them.
  • If you have API calls under /api, ensure those are also routed correctly.
  • For SPAs, you may need to fallback to index.html for unknown paths.

On this page