Skip to content

Commit db9da49

Browse files
Documentation edits made through Mintlify web editor
1 parent f5358c8 commit db9da49

File tree

5 files changed

+102
-803
lines changed

5 files changed

+102
-803
lines changed

advanced/subpath/cloudflare.mdx

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,20 @@ import SubpathGatingSnippet from "/snippets/custom-subpath-gating.mdx";
77

88
<SubpathGatingSnippet platform="Cloudflare" />
99

10-
## Create Cloudflare Worker
10+
## Setup Instructions
1111

12-
Navigate to the `Workers & Pages > Create application > Create worker`. You
13-
should be able to presented with the following screen where you can create a new
14-
Cloudlfare worker.
12+
1. Create a Cloudflare Worker at `Workers & Pages > Create application > Create worker`
1513

16-
<Frame>
17-
<img alt="Create a Cloudflare worker" src="/images/cloudflare/worker.png" />
18-
</Frame>
14+
2. Configure Custom Domain
15+
- Go to worker `Settings > Triggers`
16+
- Click `Add Custom Domain`
17+
- Add your domain (both with and without `www.`)
1918

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](mailto:[email protected]) and we'll walk you through
36-
upgrading your hosting with us.
37-
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>
45-
46-
<Tip>
47-
Edit `DOCS_URL` by replacing `[SUBDOMAIN]` with your unique subdomain and
48-
`CUSTOM_URL` with your website's base URL.
49-
</Tip>
19+
3. Add Worker Script
20+
- Click `Edit Code`
21+
- Paste the script below
22+
- Replace `[SUBDOMAIN]` and `[YOUR_DOMAIN]` with your values
23+
- Click `Deploy`
5024

5125
```javascript
5226
addEventListener("fetch", (event) => {
@@ -56,29 +30,24 @@ addEventListener("fetch", (event) => {
5630
async function handleRequest(request) {
5731
try {
5832
const urlObject = new URL(request.url);
59-
// If the request is to the docs subdirectory
6033
if (/^\/docs/.test(urlObject.pathname)) {
61-
// Then Proxy to Mintlify
6234
const DOCS_URL = "[SUBDOMAIN].mintlify.dev";
6335
const CUSTOM_URL = "[YOUR_DOMAIN]";
6436

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

6840
let proxyRequest = new Request(url, request);
69-
7041
proxyRequest.headers.set("Host", DOCS_URL);
7142
proxyRequest.headers.set("X-Forwarded-Host", CUSTOM_URL);
7243
proxyRequest.headers.set("X-Forwarded-Proto", "https");
7344

7445
return await fetch(proxyRequest);
7546
}
7647
} catch (error) {
77-
// if no action found, play the regular request
7848
return await fetch(request);
7949
}
8050
}
8151
```
8252

83-
Click on `Deploy` and wait for the changes to propagate (it can take up to a few
84-
hours).
53+
Note: Changes may take a few hours to propagate. For setup assistance, [contact our support team](mailto:[email protected]).

0 commit comments

Comments
 (0)