Skip to content

feature/md-2326-allow-multi-domains-per-worker - #44

Draft
filipe-boleto wants to merge 1 commit into
mainfrom
feature/md-2326-allow-multi-domain-per-worker
Draft

filipe-boleto wants to merge 1 commit into
mainfrom
feature/md-2326-allow-multi-domain-per-worker

Conversation

@filipe-boleto

Copy link
Copy Markdown
Contributor

No description provided.

@filipe-boleto
filipe-boleto force-pushed the feature/md-2326-allow-multi-domain-per-worker branch from ef15c77 to 4110bbf Compare August 10, 2026 13:27
@filipe-boleto
filipe-boleto requested review from JFL110 and benney and a balanced review from Copilot and removed request for benney August 10, 2026 13:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds multi-domain host routing while preserving existing single-domain behavior.

Changes:

  • Adds validated domain maps with per-domain origins, surfaces, and secrets.
  • Refactors proxy construction and Cloudflare HTML rewriting.
  • Adds configuration documentation, examples, metadata, and tests.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
worker-configuration.d.ts Types the optional domain map binding.
src/domainMap.ts Parses, validates, and resolves domain configurations.
src/proxyConfig.ts Builds single- or multi-domain proxies.
src/htmlRewriter.ts Extracts the Cloudflare HTML adapter.
src/index.ts Uses the refactored proxy factory.
test/domainMap.spec.ts Tests domain-map utilities.
test/proxyConfig.spec.ts Tests host routing and unknown hosts.
README.md Documents multi-domain setup.
package.json Adds deployment binding metadata.
config/domain-map.example.json Provides an example domain map.
Suppressed comments (1)

src/domainMap.ts:146

  • An explicitly configured DOMAIN_MAP: {} is treated as if the binding were absent, so resolveConfigSource bypasses this module's empty-map validation and silently falls back to single-domain mode. If legacy single-domain variables remain set, attached hosts can then be proxied to that origin instead of failing closed. Treat any object binding as present and update the corresponding test so {} reaches loadDomainMap and is rejected.
    if (typeof raw === 'object' && !Array.isArray(raw)) return Object.keys(raw).length > 0

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/domainMap.ts
Comment on lines +57 to +60
if (lower.startsWith('[')) {
const end = lower.indexOf(']')
return end === -1 ? lower : lower.slice(1, end)
}
Comment thread src/proxyConfig.ts
Comment on lines +31 to +33
originUrl: entry.originUrl,
surfaceSlug: entry.surfaceSlug,
mosSecretKey: entry.mosSecretKey,
@benney

benney commented Aug 10, 2026

Copy link
Copy Markdown
Member

Why this and not just use the hostPathMatcher provided by mos proxy? We already have instructions in the README there, I'm not sure we need anything more than an example in the README in this repo either? https://github.com/MonetizationOS/mos-proxy#per-request-config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants