feat(github): allow extra OAuth redirect hosts via env var - #552
Merged
Conversation
`allowedRedirectHosts` was a source literal pinned to `decocms.com`, so a self-hosted Mesh/Studio on its own domain could not complete the GitHub OAuth flow at all. Add `EXTRA_ALLOWED_REDIRECT_HOSTS` — a comma-separated list of extra host suffixes merged with the built-in one. Entries may be pasted as full callback URLs (reduced to their host, since matching is per-host) and are lowercased, trimmed and deduped; single-label values (`com`, `localhost`) are rejected because as a *suffix* they would open a whole TLD. Unusable entries are logged and skipped rather than throwing, so one typo cannot take OAuth down for every install. Keeping the hosts in deployment config rather than in source means no install-specific hostname lands in this repo.
viktormarinho
enabled auto-merge (squash)
September 3, 2026 18:29
viktormarinho
disabled auto-merge
September 3, 2026 18:29
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.
Problem
oauth.allowedRedirectHostswas a source literal pinned todecocms.com, so aself-hosted Mesh/Studio on its own domain could not complete the GitHub OAuth
flow at all — GitHub delivers the authorization
codeto theredirect_uri,and this server refuses to hand GitHub a callback outside the allowlist.
Change
EXTRA_ALLOWED_REDIRECT_HOSTS— a comma-separated list of extra host suffixes,merged with the built-in
decocms.com:(matching is per-host, the path is irrelevant);
com,localhost) are rejected, because as a suffixthey would open a whole TLD;
the list cannot take OAuth down for every install.
Hosts live in deployment config rather than in source on purpose, so no
install-specific hostname lands in this public repo.
Each added host is one more origin that can receive a user's authorization
code, so this is documented as "only hosts you trust as much asdecocms.com".Note for deployers
Adding a host takes two steps, both documented in the README: the env var
here, and the exact callback URL under the GitHub App's Callback URL setting
(GitHub Apps allow several). Without the second, GitHub rejects the authorize
request regardless of what this server permits.
Test plan
bun testingithub/— 133 pass / 0 fail, including 9 new cases inserver/constants.test.ts(bare host, full URL, casing/whitespace,single-label rejection, unparseable entries, dedupe, partial-failure).
bun run check— no errors ingithub/server/**(remainingtscoutputis pre-existing noise from
@decocms/runtimeinnode_modules).Summary by cubic
Previously, GitHub OAuth callbacks were limited to
decocms.com, preventing self-hosted Mesh/Studio deployments from completing OAuth. The server now accepts additional hosts throughEXTRA_ALLOWED_REDIRECT_HOSTS; invalid entries are logged and skipped, and each added host must be trusted to receive authorization codes.Migration
EXTRA_ALLOWED_REDIRECT_HOSTSto a comma-separated list of trusted host suffixes or callback URLs.Written for commit 3e53dd6. Summary will update on new commits.