fix(server): add cors to modular routes

This commit is contained in:
Brendan Allan 2026-07-17 07:26:09 +00:00
commit 56ea8a4a49
2 changed files with 56 additions and 3 deletions

View file

@ -0,0 +1,17 @@
import { describe, expect, test } from "bun:test"
import { webHandler } from "../src/routes"
describe("server CORS", () => {
test("adds CORS headers to /api/health 404 responses", async () => {
const response = await webHandler().handler(
new Request("http://localhost/api/health", {
method: "POST",
headers: { origin: "https://app.opencode.ai" },
}),
)
expect(response.status).toBe(404)
expect(response.headers.get("access-control-allow-origin")).toBe("https://app.opencode.ai")
expect(response.headers.get("vary")).toContain("Origin")
})
})