Cloudflare
Host documentation at a /docs subpath using Cloudflare Workers
To host your documentation at a /docs
subpath using Cloudflare, you will need to create and configure a Cloudflare Worker.
Before you begin, you need a Cloudflare account and a domain name (can be managed on or off Cloudflare).
Set up a Cloudflare Worker
Create a Cloudflare Worker by following the Cloudflare Workers getting started guide, if you have not already.
If your DNS provider is Cloudflare, do not use proxying for the CNAME record.
Configure routing
In your Cloudflare dashboard, select Edit Code and add the following script into your Worker’s code. See the Cloudflare documentation for more information on editing a Worker.
Replace [SUBDOMAIN]
with your unique subdomain and [YOUR_DOMAIN]
with your website’s base URL.
Select Deploy
and wait for the changes to propagate (it can take up to a few
hours).
Test your Worker
After your code deploys, test your Worker to ensure it routes to your Mintlify docs.
- Test using the Worker’s preview URL:
your-worker.your-subdomain.workers.dev/docs
- Verify the Worker routes to your Mintlify docs and your website.
Add custom domain
- In your Cloudflare dashboard, navigate to your Worker.
- Go to Settings > Domains & Routes > Add > Custom Domain.
- Add your domain.
We recommend you add your domain both with and without www.
prepended.
See Add a custom domain in the Cloudflare documentation for more information.
Resolve DNS conflicts
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.
- Delete the existing DNS record for your domain. See Delete DNS records in the Cloudflare documentation for more information.
- Return to your Worker and add your custom domain.
Webflow custom routing
If you use Webflow to host your main site and want to serve Mintlify docs at /docs
on the same domain, you’ll need to configure custom routing through Cloudflare Workers to proxy all non-docs traffic to your main site.
Make sure your main site is set up on a landing page before deploying this Worker, or visitors to your main site will see errors.
- In Webflow, set up a landing page for your main site like
landing.yoursite.com
. This will be the page that visitors see when they visit your site. - Deploy your main site to the landing page. This ensures that your main site remains accessible while you configure the Worker.
- To avoid conflicts, update any absolute URLs in your main site to be relative.
- In Cloudflare, select Edit Code and add the following script into your Worker’s code.
[SUBDOMAIN]
with your unique subdomain, [YOUR_DOMAIN]
with your website’s base URL, and [LANDING_DOMAIN]
with your landing page URL. - Select Deploy and wait for the changes to propagate, which can take up to a few hours.