Add disable_seo config to keep preview deployments out of search engines

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-15 05:29:08 +01:00
co-authored by Claude Opus 5.5
parent 3a75880ae4
commit 23a309005a
14 changed files with 117 additions and 3 deletions
+20
View File
@@ -827,6 +827,25 @@ const config: BunextConfig = {
To serve it from a route instead, `bunext.bunextGenerateRobotsTxt()` takes the same options except `output` and returns the text.
### Disabling SEO
For preview or test deployments that must never be indexed, set `disable_seo`:
```ts
// bunext.config.ts
const config: BunextConfig = {
disable_seo: process.env.PREVIEW === "true",
};
```
With it on, the server:
- adds `X-Robots-Tag: noindex, nofollow` to every response (pages, API routes and files),
- renders `<meta name="robots" content="noindex, nofollow">` on every page, replacing any `meta.robots`,
- answers `/robots.txt` with `Disallow: /` for all crawlers, ignoring `public/robots.txt`.
Nothing is written to disk, so the same build can be deployed to production with the option off. Responses returned directly by [middleware](#middleware) are left untouched.
---
## Static Files
@@ -971,6 +990,7 @@ export default config;
| `serverOptions` | `ServeOptions` | — | Extra options passed to `Bun.serve()` (excluding `fetch`) — see [Server Options](#server-options) |
| `sitemap` | `BunextSitemapConfig` | — | Options for `bunext sitemap` — see [Sitemap](#sitemap) |
| `robots` | `BunextRobotsConfig \| false` | — | robots.txt options for `bunext sitemap`, or `false` to skip it — see [robots.txt](#robotstxt) |
| `disable_seo` | `boolean` | `false` | Keep the whole site out of search engines (e.g. preview deployments) — see [Disabling SEO](#disabling-seo) |
### Middleware