fix(server): preserve CORS headers on Vercel preflight and bootstrap-failure paths#1175
Merged
xuyushun441-sys merged 1 commit intomainfrom Apr 17, 2026
Merged
Conversation
…ure responses Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/5547ad9e-8774-4b29-a908-5b6c46d66d4b Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
xuyushun441-sys
April 17, 2026 04:38
View session
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Frontend requests to the Vercel-deployed
apps/serverfail with missingAccess-Control-Allow-Originon/api/v1/*. Two paths inapps/server/server/index.tsreturn rawResponseobjects that bypass the Hono app — and therefore the CORS middleware registered insidecreateHonoApp.Root cause
OPTIONSrequests fall through toensureApp(). A slow/failed cold start yields a preflight with no CORS headers, which the browser caches as a failure and then blocks every subsequent/api/v1/*GET.ensureKernel()throws, the handler returns a raw 503, so the browser surfaces a generic CORS error instead of the real status.Changes
withCorsHeaders(response, request)— clones aResponseand attachesAccess-Control-Allow-Origin/-Credentials/Vary: Origin. MirrorscreateHonoApp's env-driven defaults (CORS_ENABLED,CORS_ORIGIN,CORS_CREDENTIALS,CORS_MAX_AGE) so behaviour is identical whether or not the kernel finished booting.buildPreflightResponse(request)— produces a 204 preflight withAllow-Methods,Allow-Headers(echoingAccess-Control-Request-Headerswhen sent),Max-Age.OPTIONSbeforeensureApp(), and wrap the 503 bootstrap-failure response withwithCorsHeaders. Successful responses remain untouched; Hono'scors()still owns them.apps/server/CHANGELOG.mdupdated.Notes for reviewers
CORS_ORIGINunset +credentials=true+ noOriginheader → noACAOemitted (spec-correct: wildcard is illegal with credentials; non-browser callers don't need it).CORS_ORIGIN="a,b") is honoured on both paths; mismatched origins get noACAO.createHonoApp) is unchanged — the fix is scoped to the Vercel entrypoint that sits in front of it.