mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-17 08:05:19 +00:00
29 lines
599 B
Markdown
29 lines
599 B
Markdown
# `@gitbook/proxy`
|
|
|
|
Host a GitBook site on your own domain as a subpath.
|
|
|
|
## Usage
|
|
|
|
```ts
|
|
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,
|
|
});
|
|
},
|
|
};
|
|
```
|