> ## Documentation Index
> [HTML page](https://blode.md/docs/guides/proxy-cloudflare)
> [Documentation index](https://blode.md/docs/llms.txt)
> Use the index to discover all available pages before exploring further.

# Proxy /docs through Cloudflare Workers

Use a Cloudflare Worker to proxy /docs and /_docs paths on your domain to an Edda site, keeping marketing pages on your apex or subdomain.

Use a Cloudflare Worker to proxy any path under `/docs` to your Edda site.
Works with apex domains and subdomains.

## Worker script

```js
const TARGET = "https://acme.blode.md";

export default {
  async fetch(request) {
    const url = new URL(request.url);
    // Shared CSS, JavaScript and fonts live at the root of your domain rather
    // than under /docs, and are forwarded with the path intact.
    if (url.pathname.startsWith("/_docs/")) {
      const upstream = new URL(url.pathname + url.search, TARGET);
      return fetch(new Request(upstream, request));
    }
    if (!url.pathname.startsWith("/docs")) {
      return fetch(request);
    }
    const upstreamPath = url.pathname.replace(/^\/docs/, "") || "/";
    const upstream = new URL(upstreamPath + url.search, TARGET);
    return fetch(new Request(upstream, request));
  },
};
```

Replace `acme` with your project slug. Drop the `/_docs/` branch and the pages
still load, but as unstyled HTML: every stylesheet and script 404s.

## Routes

In **Workers → Triggers**, add a route like:

```
yourdomain.com/docs*
yourdomain.com/_docs/*
```

Cloudflare invokes the Worker for every matching request and forwards them to
your Edda site without exposing the upstream URL to users. Both routes are
required: the second is what makes the asset branch above reachable.

## Caching

Use Cloudflare&apos;s default cache behavior, or wrap the response with
`new Response(response.body, response)` and set custom `cache-control` headers
if you need fine control.

If you enable caching in the Worker, keep the `Accept` header in the cache key
or bypass the cache when it contains `text/markdown`. Edda returns Markdown
for `Accept: text/markdown` on every page URL; a cache keyed on the URL alone
hands that request the HTML it stored for a browser. Coding agents that send
the header would then read your HTML shell instead of the page.

## Strip the prefix in Edda

Set the default subdomain path prefix to `/docs` in **Dashboard → Project →
Domains**, or pass `pathPrefix: "/docs"` when creating the domain via the API,
so internal links resolve correctly.

## Declare your public URL

A proxy is invisible to us: the request we receive looks identical to someone
visiting `acme.blode.md` directly, so we cannot tell that your domain sits in
front. Tell us where the site is published:

```json docs.json
{
  "seo": {
    "siteUrl": "https://yourdomain.com/docs"
  }
}
```

Include the path prefix if you use one. Canonical tags, `og:url`, JSON-LD, the
sitemap, `llms.txt` and the `.md` alternates are all built from this value.
Skip it and every page canonicalises to `acme.blode.md` instead of your domain.