Configuring a subdirectory with Cloudflare
Host your documentation with a /docs subdirectory using Cloudflare
4
Update the worker code
export default {
fetch(request) {
const SUBDIRECTORY = '/docs';
const url = new URL(request.url);
const target = "<INSERT YOUR PROXY URL FROM GITBOOK>" + url.pathname.slice(SUBDIRECTORY.length);
const proxy = new URL(
target.endsWith('/') ? target.slice(0, -1) : target
)
proxy.search = url.search;
return fetch(new Request(proxy, request));
}
};Last updated
Was this helpful?