Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions deploy/cloudflare.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

The dashboard displays a Cloudflare Worker script with your subdomain, domain, and base path filled in. Use this script in the [Configure routing](#configure-routing) step instead of manually replacing the placeholder values in the example script.

## Set up a Worker

Check warning on line 24 in deploy/cloudflare.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/cloudflare.mdx#L24

'Set up a Worker' should use sentence-style capitalization.

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.

Expand Down Expand Up @@ -70,8 +70,12 @@
return await fetch(request);
}

// If the request is to the docs subpath
if (/^\/docs/.test(urlObject.pathname)) {
// If the request is to the docs subpath or a Mintlify asset or API path
if (
/^\/docs/.test(urlObject.pathname) ||
/^\/mintlify-assets\//.test(urlObject.pathname) ||
/^\/_mintlify\//.test(urlObject.pathname)
) {
// Then Proxy to Mintlify
const DOCS_URL = "[SUBDOMAIN].mintlify.site";
const CUSTOM_URL = "[YOUR_DOMAIN]";
Expand All @@ -96,11 +100,17 @@
}
```

<Warning>
In addition to your subpath, your Worker must proxy `/mintlify-assets/*`, which serves the CSS, JavaScript, and favicons for your documentation, and `/_mintlify/*`, which handles API playground requests.

If you route traffic to your Worker with route patterns instead of a custom domain, add routes for `yoursite.com/mintlify-assets/*` and `yoursite.com/_mintlify/*` alongside your subpath route. These paths must originate from the root of your domain, not your subpath.
</Warning>

Click **Deploy** and wait for the changes to propagate.

<Propagating />

### Test your Worker

Check warning on line 113 in deploy/cloudflare.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/cloudflare.mdx#L113

'Test your Worker' should use sentence-style capitalization.

After your code deploys, test your Worker to ensure it routes to your Mintlify docs.

Expand Down Expand Up @@ -154,8 +164,12 @@
return await fetch(request);
}

// If the request is to the docs subpath
if (/^\/docs/.test(urlObject.pathname)) {
// If the request is to the docs subpath or a Mintlify asset or API path
if (
/^\/docs/.test(urlObject.pathname) ||
/^\/mintlify-assets\//.test(urlObject.pathname) ||
/^\/_mintlify\//.test(urlObject.pathname)
) {
// Proxy to Mintlify
const DOCS_URL = "[SUBDOMAIN].mintlify.site";
const CUSTOM_URL = "[YOUR_DOMAIN]";
Expand Down
16 changes: 14 additions & 2 deletions deploy/route53-cloudfront.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
- `/.well-known/vercel/*` - Required for domain verification
- `/docs/*` - Required for subpath routing
- `/docs/` - Required for subpath routing
- `/_mintlify/*` - Required for API playground requests

Route traffic to these paths with a Cache Policy of **CachingEnabled**:

- `/mintlify-assets/_next/static/*`
- `/mintlify-assets/*` - Required for CSS, JavaScript, and favicons
- `Default (*)` - Your website's landing page

All Behaviors must have an **origin request policy** of `AllViewerExceptHostHeader`.
Expand Down Expand Up @@ -134,7 +135,7 @@
- Set "Cache policy" to **CachingDisabled**.
- Set "Origin request policy" to **AllViewerExceptHostHeader**.
- Set "Viewer protocol policy" to **Redirect HTTP to HTTPS**.
- Set "Allowed HTTP methods" to **GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE**.

Check warning on line 138 in deploy/route53-cloudfront.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/route53-cloudfront.mdx#L138

Spell out 'HEAD', if it's unfamiliar to the audience.

Check warning on line 138 in deploy/route53-cloudfront.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/route53-cloudfront.mdx#L138

Spell out 'PUT', if it's unfamiliar to the audience.

Check warning on line 138 in deploy/route53-cloudfront.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/route53-cloudfront.mdx#L138

Spell out 'PATCH', if it's unfamiliar to the audience.

<Warning>
CloudFront only allows `GET` and `HEAD` requests by default. If you don't allow all HTTP methods, CloudFront rejects the `POST` requests that Mintlify uses for analytics, and your dashboard won't show any page views even though your docs load normally.
Expand All @@ -153,14 +154,25 @@
- Set "Cache policy" to **CachingDisabled**.
- Set "Origin request policy" to **AllViewerExceptHostHeader**.
- Set "Viewer protocol policy" to **Redirect HTTP to HTTPS**.
- Set "Allowed HTTP methods" to **GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE**.

Check warning on line 157 in deploy/route53-cloudfront.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/route53-cloudfront.mdx#L157

Spell out 'HEAD', if it's unfamiliar to the audience.

Check warning on line 157 in deploy/route53-cloudfront.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/route53-cloudfront.mdx#L157

Spell out 'PUT', if it's unfamiliar to the audience.

Check warning on line 157 in deploy/route53-cloudfront.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/route53-cloudfront.mdx#L157

Spell out 'PATCH', if it's unfamiliar to the audience.

### `/mintlify-assets/_next/static/*`
### `/mintlify-assets/*`

Create a behavior with a **Path pattern** of `/mintlify-assets/*` with **Origin and origin groups** pointing to the `.mintlify.site` URL. This path serves the CSS, JavaScript, and favicons for your documentation from the root of your domain.

- Set "Cache policy" to **CachingOptimized**.
- Set "Origin request policy" to **AllViewerExceptHostHeader**.
- Set "Viewer protocol policy" to **Redirect HTTP to HTTPS**.

### `/_mintlify/*`

Create a behavior with a **Path pattern** of `/_mintlify/*` with **Origin and origin groups** pointing to the `.mintlify.site` URL. This path handles API playground requests from the root of your domain.

- Set "Cache policy" to **CachingDisabled**.
- Set "Origin request policy" to **AllViewerExceptHostHeader**.
- Set "Viewer protocol policy" to **Redirect HTTP to HTTPS**.
- Set "Allowed HTTP methods" to **GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE**.

Check warning on line 174 in deploy/route53-cloudfront.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/route53-cloudfront.mdx#L174

Spell out 'HEAD', if it's unfamiliar to the audience.

Check warning on line 174 in deploy/route53-cloudfront.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/route53-cloudfront.mdx#L174

Spell out 'PUT', if it's unfamiliar to the audience.

Check warning on line 174 in deploy/route53-cloudfront.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

deploy/route53-cloudfront.mdx#L174

Spell out 'PATCH', if it's unfamiliar to the audience.

### `Default (*)`

Edit the `Default (*)` behavior.
Expand Down