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:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user