Skip to content

Commit 5c3a627

Browse files
authored
Add DNS conflict resolution to Cloudflare subpath docs (#791)
* update cloudflare subpath page * add resolving DNS conflict section * reorder steps, add testing * update code example * Revert "update code example" This reverts commit 965de81. * move troubleshooting to end * add reviewer feedback * move prerequisites into info callout
1 parent 7cad13d commit 5c3a627

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed

advanced/subpath/cloudflare.mdx

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,26 @@ title: "Cloudflare"
33
description: "Host documentation at a /docs subpath using Cloudflare Workers"
44
---
55

6-
## Create Cloudflare Worker
6+
To host your documentation at a `/docs` subpath using Cloudflare, you will need to create and configure a Cloudflare Worker.
77

8-
Navigate to the `Workers & Pages > Create application > Create worker`. You
9-
should be presented with the following screen where you can create a new
10-
Cloudflare worker.
8+
<Info>
9+
Before you begin, you need a Cloudflare account and a domain name (can be managed on or off Cloudflare).
10+
</Info>
1111

12-
<Frame>
13-
<img alt="Create a Cloudflare worker" src="/images/cloudflare/worker.png" />
14-
</Frame>
12+
## Set up a Cloudflare Worker
13+
14+
Create a Cloudflare Worker by following the [Cloudflare Workers getting started guide](https://developers.cloudflare.com/workers/get-started/dashboard/), if you have not already.
1515

1616
<Warning>
17-
Keep in mind: If your DNS provider is Cloudflare you should not use proxying for the CNAME record
17+
If your DNS provider is Cloudflare, do not use proxying for the CNAME record.
1818
</Warning>
1919

20-
### Add custom domain
21-
22-
Once the worker is created, click `Configure worker`. Navigate to the worker
23-
`Settings > Triggers`. Click on `Add Custom Domain` to add your desired domain
24-
into the list - we recommend you add both the version with and without `www.`
25-
prepended to the domain.
26-
27-
<Frame>
28-
<img
29-
alt="Cloudflare worker custom domain"
30-
src="/images/cloudflare/custom-domain.png"
31-
/>
32-
</Frame>
33-
34-
If you have trouble setting up a custom subdirectory,
35-
[contact our support team](https://mintlify.com/docs/support) and we'll walk you through
36-
upgrading your hosting with us.
20+
### Configure routing
3721

38-
### Edit Worker Script
39-
40-
Click on `Edit Code` and add the following script into the worker's code.
41-
42-
<Frame>
43-
<img alt="Cloudflare edit code" src="/images/cloudflare/edit-code.png" />
44-
</Frame>
22+
In your Cloudflare dashboard, select **Edit Code** and add the following script into your Worker's code. See the [Cloudflare documentation](https://developers.cloudflare.com/workers-ai/get-started/dashboard/#development) for more information on editing a Worker.
4523

4624
<Tip>
47-
Edit `DOCS_URL` by replacing `[SUBDOMAIN]` with your unique subdomain and
48-
`CUSTOM_URL` with your website's base URL.
25+
Replace `[SUBDOMAIN]` with your unique subdomain and `[YOUR_DOMAIN]` with your website's base URL.
4926
</Tip>
5027

5128
```javascript
@@ -80,5 +57,31 @@ async function handleRequest(request) {
8057
}
8158
```
8259

83-
Click on `Deploy` and wait for the changes to propagate (it can take up to a few
60+
Select `Deploy` and wait for the changes to propagate (it can take up to a few
8461
hours).
62+
63+
### Test your Worker
64+
65+
After your code deploys, test your Worker to ensure it routes to your Mintlify docs.
66+
67+
1. Test using the Worker's preview URL: `your-worker.your-subdomain.workers.dev/docs`
68+
2. Verify the Worker routes to your Mintlify docs and your website.
69+
70+
### Add custom domain
71+
72+
1. In your [Cloudflare dashboard](https://dash.cloudflare.com/), navigate to your Worker.
73+
2. Go to **Settings > Domains & Routes > Add > Custom Domain**.
74+
3. Add your domain.
75+
76+
<Tip>
77+
We recommend you add your domain both with and without `www.` prepended.
78+
</Tip>
79+
80+
See [Add a custom domain](https://developers.cloudflare.com/workers/configuration/routing/custom-domains/#add-a-custom-domain) in the Cloudflare documentation for more information.
81+
82+
### Resolve DNS conflicts
83+
84+
If your domain already points to another service, you must remove the existing DNS record. Your Cloudflare Worker must be configured to control all traffic for your domain.
85+
86+
1. Delete the existing DNS record for your domain. See [Delete DNS records](https://developers.cloudflare.com/dns/manage-dns-records/how-to/create-dns-records/#delete-dns-records) in the Cloudflare documentation for more information.
87+
2. Return to your Worker and add your custom domain.

0 commit comments

Comments
 (0)