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
@@ -123,4 +123,29 @@ describe("bunext-req-handler", () => {
const res = await bunextRequestHandler({ req, server });
expect(await res.text()).toBe("web-pages");
});
test("disable_seo blocks crawlers via header and robots.txt", async () => {
global.BUNEXT_CONSTANTS.config.disable_seo = true;
const page = await bunextRequestHandler({
req: new Request("http://localhost/about"),
server,
});
expect(page.headers.get("X-Robots-Tag")).toBe("noindex, nofollow");
const robots = await bunextRequestHandler({
req: new Request("http://localhost/robots.txt"),
server,
});
expect(await robots.text()).toContain("User-agent: *\nDisallow: /");
expect(robots.headers.get("X-Robots-Tag")).toBe("noindex, nofollow");
});
test("no X-Robots-Tag without disable_seo", async () => {
const res = await bunextRequestHandler({
req: new Request("http://localhost/about"),
server,
});
expect(res.headers.get("X-Robots-Tag")).toBeNull();
});
});