Files
gitbook/packages/proxy
Samy Pessé f64d5073d4 Version Packages (#2557)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-12-18 10:25:08 +01:00
..
2024-12-18 10:25:08 +01:00
2024-12-18 10:25:08 +01:00

@gitbook/proxy

Host a GitBook site on your own domain as a subpath.

Usage

import { proxyToGitBook } from '@gitbook/proxy';

const site = proxyToGitBook(event.request, {
    site: 'mycompany.gitbook.io/site/',
    basePath: '/docs',
});

export default {
    async fetch(request) {
        // If the requst matches the basePath /docs, we serve from GitBook
        if (site.match(request)) {
            return site.fetch(request);
        }

        // Otherwise we do something else.
        return new Response('Not found', {
            statusCode: 404,
        });
    },
};