Skip to content

fix(serve): honor --cors for the decision server - #256

Draft
shubhamsinnh wants to merge 2 commits into
RunanywhereAI:mainfrom
shubhamsinnh:fix/decision-cors
Draft

shubhamsinnh wants to merge 2 commits into
RunanywhereAI:mainfrom
shubhamsinnh:fix/decision-cors

Conversation

@shubhamsinnh

@shubhamsinnh shubhamsinnh commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

wally serve --cors was ignored for decision models, so browser preflight requests returned 404 without CORS headers.

The decision server now receives the flag, answers OPTIONS before routing, and adds CORS headers to both successful and error responses. Behavior without --cors stays the same.

Validation with a real decision model covered default-off behavior, preflight 204, POST 200, and headers on 400/404/413/431 responses. Browser validation and the runtime 500 path were not exercised.

CI and formatting pass. The local full suite had 565 passes and two Windows symlink-privilege failures. Strict Clippy reports four pre-existing lints in untouched files.


Summary by cubic

Fixes --cors being ignored by the local decision server, so browser-based decision requests now behave like the LLM server. Previously the flag applied only to the LLM server; a decision model routed to the local decision endpoint skipped it and OPTIONS preflight returned 404.

  • Passes --cors through to the decision server and answers OPTIONS with 204 before method/path routing, omitting Content-Length on 204 responses per RFC 9110.
  • Adds the same Access-Control-Allow-Origin, Access-Control-Allow-Methods, and Access-Control-Allow-Headers values the LLM server uses to every response, errors included.
  • Behavior without --cors is unchanged.

Written for commit 63bd340. Summary will update on new commits.

View guided diff

The --cors flag reached the LLM server but was dropped when serve routed
a decision model to its local decision endpoint.

Pass the flag through to the decision server, answer OPTIONS with 204,
and add the same Access-Control headers the SDK LLM server uses to every
response, including 400/404/413/431 and 500. Without --cors the behavior
is unchanged.

Validated with the GLiNER 2.5 Decide model: preflight returns 204 with
the headers, POST returns the same decision JSON with the headers, and
error responses carry them too. Browser-level CORS validation was not
performed.
@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

RFC 9110 section 8.6 forbids Content-Length on 204 responses, including an explicit zero. Keep the normal JSON response framing for other statuses.

Verified eight raw TCP exchanges with a real decision model and all five existing serve tests. Browser behavior remains unverified.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant