fix: fall back to OSC_HOSTNAME when CORS_ORIGIN is not set - #385
Merged
Merged
Conversation
PR #346 made CORS_ORIGIN a required env var, so instances on Eyevinn Open Source Cloud (where arbitrary per-instance env vars can't be set) failed to boot. Resolve the allowed origin from CORS_ORIGIN first, then fall back to the OSC-injected OSC_HOSTNAME, and only fail fast when neither is set. Closes #383
Contributor
Author
|
Independent Self-authored PR (author == automation account |
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_ORIGINa hard-required env var (OSC has no way to set arbitrary per-instance env vars).src/config/cors-origin.ts) that resolves the allowed CORS origin fromCORS_ORIGINfirst, then falls back to the OSC-injectedOSC_HOSTNAME(bare hostname → prefixedhttps://; full URL → trailing slash stripped; empty/whitespace treated as unset).src/api.tsCORS registration andvalidateRequiredEnv()insrc/server.tsboth use the shared resolver, so they stay in agreement. Startup still fails fast (exit 1) only when neither is set. ExplicitCORS_ORIGINstill wins overOSC_HOSTNAME. The WHIP/WHEP permissive CORS branch is unchanged.readme.mdCORS_ORIGINrow.Test plan
npm test— 392 passed / 20 suites)npm run typecheck)npm run lint— only pre-existing warnings)CORS_ORIGINunset andOSC_HOSTNAMEsetCORS_ORIGINwins overOSC_HOSTNAMECORS_ORIGINtreated as unsethttps://; full URL trailing slash strippedCloses #383
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com