Files
morulia/test/headers.test.ts
CatoandClaude abb53a2fab fix(headers): same-origin referrer policy so the sign-in form can start (#37)
With `Referrer-Policy: no-referrer` browsers send `Origin: null` on the
same-origin POST to /start. start() requires its own origin, so every
provider button ended on /problem?error=start_failed. Found live on
2026-11-10, the first time a provider (Google) was switched on; the tests
call the handler with `origin` set by hand and could not see it.

`same-origin` keeps what no-referrer was for (nothing about a sign-in
reaches a provider or any other site) and lets the form send its origin.
Checked in Chromium: no-referrer -> `Origin: null`, same-origin -> the origin.
A test pins the policy.


Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-10 08:53:30 +01:00

16 lines
790 B
TypeScript

import { describe, expect, it } from "vitest";
import config from "../next.config";
describe("response headers", () => {
it("lets the sign-in form send its own origin, and still tells other sites nothing", async () => {
// Found live 2026-11-10: with `Referrer-Policy: no-referrer` browsers send
// `Origin: null` on the same-origin POST to /start, which `start()` refuses,
// so every provider button landed on /problem?error=start_failed. The tests
// that call the handler set `origin` by hand and could not see it.
const rules = (await config.headers?.()) ?? [];
const policy = rules.flatMap((rule) => rule.headers).find((h) => h.key === "Referrer-Policy")?.value;
expect(policy).not.toBe("no-referrer");
expect(policy).toBe("same-origin");
});
});