Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/cloudflare-api-site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ FORGE_OPENAPI_RELEASE='openapi@<api-schemas-commit>' pnpm --filter cloudflare-ap
Set `FORGE_OPENAPI_SPEC` to an already-downloaded artifact to build without
downloading it again.

Astro trusts the `X-Forwarded-Host` header only for hosts listed in
[`security.allowedDomains`](https://docs.astro.build/en/reference/configuration-reference/#securityalloweddomains)
(`cloudflare.com` and its subdomains, over HTTPS). For an internal deployment, set
`INTERNAL_SITE_DOMAIN` to its hostname (for example `docs.internal.example`)
when building to add it to the list:

```bash
INTERNAL_SITE_DOMAIN='<internal-hostname>' pnpm --filter cloudflare-api-site build
```

`check` validates the Astro components. `build` verifies the Cloudflare SSR
bundle.

Expand Down
11 changes: 11 additions & 0 deletions packages/cloudflare-api-site/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ import astroFern from 'astro-fern';

const site = 'https://docs.experiments.devprod.cloudflare.dev';

const internalSiteDomain = process.env['INTERNAL_SITE_DOMAIN']?.trim();
// `*.cloudflare.com` only one sub domain on purpose
const allowedDomains = [
{ protocol: 'https', hostname: '*.cloudflare.com' },
{ protocol: 'https', hostname: '**.cloudflare.dev' },
];
if (internalSiteDomain) {
allowedDomains.push({ protocol: 'https', hostname: internalSiteDomain });
}

const nimbusConfig = defineNimbusConfig({
site,
title: 'Cloudflare API',
Expand All @@ -24,6 +34,7 @@ export default defineConfig({
output: 'server',
trailingSlash: 'always',
adapter: cloudflare({ prerenderEnvironment: 'node' }),
security: { allowedDomains },
vite: {
plugins: [tailwindcss()],
// astro-fern builds operation artifact URLs from `site`, and in dev the
Expand Down
Loading