Skip to content
Closed
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
33 changes: 33 additions & 0 deletions advanced/subpath/vercel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: "Vercel"
description: "Host documentation at a /docs subpath using Vercel"
---

<Snippet file="snippets/custom-subpath-gating.mdx" />

## vercel.json Configuration

To host your documentation at a custom subpath using Vercel, you need to add the
Expand All @@ -28,3 +30,34 @@ following configuration to your `vercel.json` file.
rewrites: [Project Configuration:
Rewrites](https://vercel.com/docs/projects/project-configuration#rewrites)
</Note>

## Alternative: Subdomain Routing

If you're using a subdomain setup, you can use the following script to handle routing between your documentation and landing page domains. This approach gives you more control over the routing behavior:

```javascript
function handleRequest(request) {
const url = new URL(request.url);

// Route /docs paths to Mintlify docs domain, excluding docs.json
if (url.pathname.toLocaleLowerCase().startsWith('/docs') && !url.pathname.toLocaleLowerCase().startsWith('/docs.json')) {
url.hostname = 'mintlify.mintlify.dev';
return fetch(url.toString(), request);
} else {
// All other paths go to landing page domain
url.hostname = 'landing.mintlify.com';
return fetch(url.toString(), request);
}
}

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

This script provides:
- Routing of all `/docs/*` paths to your Mintlify documentation domain
- Special handling to exclude `docs.json` from being redirected
- Fallback routing to your landing page domain for all other paths

Add this script to your Vercel project to enable the subdomain routing functionality.
31 changes: 24 additions & 7 deletions mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@
{
"group": "Editing",
"icon": "pen-paintbrush",
"pages": ["development", "web-editor"]
"pages": [
"development",
"web-editor"
]
},
"settings/global",
"settings/navigation",
Expand Down Expand Up @@ -120,14 +123,18 @@
{
"icon": "code",
"group": "Custom Scripts",
"pages": ["advanced/custom/css", "advanced/custom/js"]
"pages": [
"advanced/custom/css",
"advanced/custom/js"
]
},
{
"icon": "folder",
"group": "Custom Subdirectory",
"pages": [
"advanced/subpath/cloudflare",
"advanced/subpath/route53-cloudfront",
"advanced/subpath/vercel",
"advanced/subpath/vercel"
]
},
Expand Down Expand Up @@ -164,7 +171,9 @@
{
"icon": "plug",
"group": "Extensions",
"pages": ["advanced/widget/chat"]
"pages": [
"advanced/widget/chat"
]
},
{
"icon": "brackets-curly",
Expand Down Expand Up @@ -210,7 +219,10 @@
},
{
"group": "SDKs",
"pages": ["integrations/sdks/speakeasy", "integrations/sdks/stainless"]
"pages": [
"integrations/sdks/speakeasy",
"integrations/sdks/stainless"
]
},
{
"group": "Support",
Expand All @@ -222,7 +234,10 @@
},
{
"group": "Privacy",
"pages": ["integrations/privacy/overview", "integrations/privacy/osano"]
"pages": [
"integrations/privacy/overview",
"integrations/privacy/osano"
]
},
{
"group": "Components",
Expand Down Expand Up @@ -254,7 +269,9 @@
},
{
"group": "Changelog",
"pages": ["changelog/overview"]
"pages": [
"changelog/overview"
]
}
],
"footer": {
Expand Down Expand Up @@ -338,4 +355,4 @@
"publicApiKey": "pk_76a6caa274e800f3ceff0b2bc6b9b9d82ab8"
}
}
}
}