Fix CORS_ORIGIN wildcard patterns on Vercel deployments#1177
Merged
xuyushun441-sys merged 1 commit intomainfrom Apr 17, 2026
Merged
Fix CORS_ORIGIN wildcard patterns on Vercel deployments#1177xuyushun441-sys merged 1 commit intomainfrom
xuyushun441-sys merged 1 commit intomainfrom
Conversation
…t short-circuit Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/4eda94c5-dea3-49b4-9f32-f9d97a0d7045 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 09:43
View session
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Apr 17, 2026
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.
Setting
CORS_ORIGIN="https://*.objectui.org,https://*.objectstack.ai,http://localhost:*"caused browser CORS errors on Vercel, even though the same value worked behind the Hono plugin'scors()middleware.Root cause
apps/server/server/index.tsshort-circuits OPTIONS preflight before the Hono app runs (so cold starts / bootstrap failures can't strip CORS headers). ItsresolveAllowOrigin()matched with a literalArray.includes(requestOrigin)—*was treated as a plain character, so every preflight from a real subdomain returned 204 with noAccess-Control-Allow-Origin, blocking all subsequent requests.The Hono middleware already implemented wildcard matching correctly, but the Vercel bypass path had a divergent, exact-match-only implementation.
Changes
matchOriginPattern/createOriginMatcher/hasWildcardPattern/normalizeOriginPatternsintopackages/plugins/plugin-hono-server/src/pattern-matcher.tsand exported from the package entry.hono-plugin.ts— removed inline copies, imports from the shared module.apps/server/server/index.ts—resolveAllowOrigin()now delegates tocreateOriginMatcher/hasWildcardPatternwhenCORS_ORIGINcontains*, so the Vercel preflight short-circuit and the Hono middleware have identical semantics.pattern-matcher.test.tsnow imports the real module (no inline duplicate) and adds coverage forhasWildcardPattern,normalizeOriginPatterns, and empty-origin handling.