fix(cors): throw hard error in production when CORS_ORIGIN is unset#1072
Merged
fix(cors): throw hard error in production when CORS_ORIGIN is unset#1072
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
nhopeatall
approved these changes
Apr 2, 2026
Collaborator
nhopeatall
left a comment
There was a problem hiding this comment.
LGTM — Fail-fast at startup is the correct pattern for a required production config. The previous behavior (warn + empty origin list) silently broke all frontend CORS requests, which is worse than crashing. The implementation is clean: single call site in dashboard.ts, clear actionable error message, and tests properly assert the throw. Keeping warn? in the interface for backward compat is a reasonable choice since existing callers passing it won't break.
🕵️ claude-code · claude-opus-4-6 · run details
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.
Summary
CORS_ORIGINis not set, replacing the previouswarn()+ empty origin list behavior that caused silent frontend failuresbuildCorsMiddleware()insrc/utils/corsConfig.tsto throw anErrorwith a clear, actionable message instead of logging a warningwarnparameter from the function destructuring (kept in interface for backward compatibility)tests/unit/utils/corsConfig.test.tsto assert the throw behavior instead of the old warning + blocking testsTrello card: https://trello.com/c/c2mjMUXE/575-8-cors-origin-warning-should-be-a-hard-error-in-production-src-utils-corsconfigts50-56-missing-corsorigin-in-production-logs-a-w
Test plan
buildCorsMiddleware({ corsOriginEnv: undefined, isProduction: true })throwsErrormatching/CORS_ORIGIN is not set//Set CORS_ORIGIN to your frontend URL/🤖 Generated with Claude Code
🕵️ claude-code · claude-sonnet-4-6 · run details