Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

### Fixed

- Allow PUT in CORS preflight responses so browsers can call the existing `/fal/queue/requests/{requestId}` route (#480).
- Fix internal errors for specific malformed provider fields and control fixture inputs, while preserving supported input forms and defaults. `toolName` matching safely skips malformed tools, and `addFixturesFromJSON` explains its array requirement. Multipart parsing distinguishes `name` from `filename`. Invalid HTTP and WebSocket request targets return 400 while retaining existing diagnostics and HTTP journal/CORS behavior (#474)
- Reject missing Ollama tool functions and malformed Anthropic message collections before fixture matching. Reject numeric user/assistant content in Anthropic requests and numeric Gemini Interactions input (#474)
- Validate malformed tool shapes on native `/v1/chat/completions` before fixture matching or proxy forwarding, while preserving supported shorthand. Compatible routes skip `toolName` matches for non-array tools without changing the request or proxy payload (#474)
Expand Down
21 changes: 18 additions & 3 deletions src/__tests__/control-inspection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,25 @@ describe("GET/POST/DELETE /__aimock/chaos", () => {
const allowed = String(preflight.headers["access-control-allow-methods"])
.split(",")
.map((m) => m.trim());
expect(allowed).toEqual(expect.arrayContaining(["GET", "POST", "DELETE"]));
// PUT would be the only one in the whole control surface — and is not used.
expect(allowed).not.toContain("PUT");
expect(allowed).toEqual(expect.arrayContaining(["GET", "POST", "PUT", "DELETE"]));
// PUT is unused on the control surface itself (still 404s there) but IS
// dispatched for `/fal/queue/requests/{requestId}`, and the preflight
// headers are server-wide — omitting it makes browsers refuse that call.
expect((await request(`${instance.url}/__aimock/chaos`, "PUT", { body: {} })).status).toBe(404);
// The fal surface's PUT must survive a browser preflight too.
const falPreflight = await request(`${instance.url}/fal/queue/requests/r1`, "OPTIONS", {
headers: {
Origin: "http://localhost:3000",
"Access-Control-Request-Method": "PUT",
"Access-Control-Request-Headers": "content-type",
},
});
expect(falPreflight.status).toBe(204);
expect(
String(falPreflight.headers["access-control-allow-methods"])
.split(",")
.map((m) => m.trim()),
).toEqual(expect.arrayContaining(["PUT"]));
// The journal total is a response header, so it must be readable too.
expect(String(preflight.headers["access-control-expose-headers"])).toContain("X-Total-Count");
});
Expand Down
5 changes: 4 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,10 @@ const DEFAULT_MODELS = [

const CORS_HEADERS: Record<string, string> = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, DELETE, OPTIONS",
// Every method the dispatcher serves: PUT is dispatched for
// `/fal/queue/requests/{requestId}` (status/cancel/result), so a preflight
// that omits it makes browsers refuse that call.
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "*",
// Response headers are invisible to cross-origin JS unless exposed. The
// journal's pagination total is a response header (the body stays a bare
Expand Down
Loading