diff --git a/advanced/subpath/vercel.mdx b/advanced/subpath/vercel.mdx index 859395776..9df5914d4 100644 --- a/advanced/subpath/vercel.mdx +++ b/advanced/subpath/vercel.mdx @@ -3,6 +3,8 @@ title: "Vercel" description: "Host documentation at a /docs subpath using Vercel" --- + + ## vercel.json Configuration To host your documentation at a custom subpath using Vercel, you need to add the @@ -28,3 +30,34 @@ following configuration to your `vercel.json` file. rewrites: [Project Configuration: Rewrites](https://vercel.com/docs/projects/project-configuration#rewrites) + +## 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. \ No newline at end of file diff --git a/mint.json b/mint.json index 7c9ef5c65..4ddfd9ece 100644 --- a/mint.json +++ b/mint.json @@ -59,7 +59,10 @@ { "group": "Editing", "icon": "pen-paintbrush", - "pages": ["development", "web-editor"] + "pages": [ + "development", + "web-editor" + ] }, "settings/global", "settings/navigation", @@ -120,7 +123,10 @@ { "icon": "code", "group": "Custom Scripts", - "pages": ["advanced/custom/css", "advanced/custom/js"] + "pages": [ + "advanced/custom/css", + "advanced/custom/js" + ] }, { "icon": "folder", @@ -128,6 +134,7 @@ "pages": [ "advanced/subpath/cloudflare", "advanced/subpath/route53-cloudfront", + "advanced/subpath/vercel", "advanced/subpath/vercel" ] }, @@ -164,7 +171,9 @@ { "icon": "plug", "group": "Extensions", - "pages": ["advanced/widget/chat"] + "pages": [ + "advanced/widget/chat" + ] }, { "icon": "brackets-curly", @@ -210,7 +219,10 @@ }, { "group": "SDKs", - "pages": ["integrations/sdks/speakeasy", "integrations/sdks/stainless"] + "pages": [ + "integrations/sdks/speakeasy", + "integrations/sdks/stainless" + ] }, { "group": "Support", @@ -222,7 +234,10 @@ }, { "group": "Privacy", - "pages": ["integrations/privacy/overview", "integrations/privacy/osano"] + "pages": [ + "integrations/privacy/overview", + "integrations/privacy/osano" + ] }, { "group": "Components", @@ -254,7 +269,9 @@ }, { "group": "Changelog", - "pages": ["changelog/overview"] + "pages": [ + "changelog/overview" + ] } ], "footer": { @@ -338,4 +355,4 @@ "publicApiKey": "pk_76a6caa274e800f3ceff0b2bc6b9b9d82ab8" } } -} +} \ No newline at end of file