opencode/packages/server/test/routes-cors.test.ts
2026-07-17 09:37:30 +00:00

17 lines
597 B
TypeScript

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")
})
})