> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-docs-simplify-quickstart-2510244c.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Cloudflare

> Host documentation at a /docs subpath using Cloudflare Workers

export const platform_0 = "Cloudflare"

<Info>
  **Prerequisite**: Your primary domain (company.com) is hosted on {platform_0}
  and you are on the [Mintlify Pro plan or above](https://mintlify.com/pricing).
</Info>

## Setup Steps

1. Create a new Cloudflare Worker at `Workers & Pages > Create application > Create worker`

<Frame>
  <img alt="Create a Cloudflare worker" src="https://mintlify.s3.us-west-1.amazonaws.com/mintlify-docs-simplify-quickstart-2510244c/images/cloudflare/worker.png" />
</Frame>

2. Add your custom domain by going to `Settings > Triggers > Add Custom Domain`
   * Add both `domain.com` and `www.domain.com` versions

<Frame>
  <img alt="Cloudflare worker custom domain" src="https://mintlify.s3.us-west-1.amazonaws.com/mintlify-docs-simplify-quickstart-2510244c/images/cloudflare/custom-domain.png" />
</Frame>

3. Click `Edit Code` and paste the following script:

<Frame>
  <img alt="Cloudflare edit code" src="https://mintlify.s3.us-west-1.amazonaws.com/mintlify-docs-simplify-quickstart-2510244c/images/cloudflare/edit-code.png" />
</Frame>

<Tip>
  Replace `[SUBDOMAIN]` and `[YOUR_DOMAIN]` in `DOCS_URL` and `CUSTOM_URL` with your values
</Tip>

```javascript
addEventListener("fetch", (event) => {
  event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
  try {
    const urlObject = new URL(request.url);
    // If the request is to the docs subdirectory
    if (/^\/docs/.test(urlObject.pathname)) {
      // Then Proxy to Mintlify
      const DOCS_URL = "[SUBDOMAIN].mintlify.dev";
      const CUSTOM_URL = "[YOUR_DOMAIN]";

      let url = new URL(request.url);
      url.hostname = DOCS_URL;

      let proxyRequest = new Request(url, request);

      proxyRequest.headers.set("Host", DOCS_URL);
      proxyRequest.headers.set("X-Forwarded-Host", CUSTOM_URL);
      proxyRequest.headers.set("X-Forwarded-Proto", "https");

      return await fetch(proxyRequest);
    }
  } catch (error) {
    // if no action found, play the regular request
    return await fetch(request);
  }
}
```

4. Click `Deploy` (changes may take a few hours to propagate)

Need help? [Contact our support team](mailto:sales@mintlify.com)
