fix(server): add cors to modular routes
This commit is contained in:
parent
efaeda00a1
commit
56ea8a4a49
2 changed files with 56 additions and 3 deletions
17
packages/server/test/routes-cors.test.ts
Normal file
17
packages/server/test/routes-cors.test.ts
Normal 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")
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue