Skip to content

fix(ep-commerce): resolve EP host when multiple global contexts share a module - #408

Merged
mzaintariq merged 2 commits into
masterfrom
fix/ep-prefer-custom-host-in-shared-global
Aug 12, 2026
Merged

fix(ep-commerce): resolve EP host when multiple global contexts share a module#408
mzaintariq merged 2 commits into
masterfrom
fix/ep-prefer-custom-host-in-shared-global

Conversation

@mzaintariq

Copy link
Copy Markdown
Collaborator

What does this MR do?

Fixes extractEpProviderConfig so it no longer takes the first host: default in a Plasmic global-contexts module. When CMS/Strapi/Shopify are nested with the EP Provider in one global__*.js, the first match was often Plasmic CMS’s https://data.plasmic.app, which the host allowlist rejects — leaving no usable EP config and breaking anonymous OAuth for storefronts that resolve credentials from the loader bundle.

Changes

  • Prefer EP’s host === "custom" + customHost when present in the module
  • Otherwise pick the first allowlisted concrete host
  • Fall back to the first non-custom host so allowlist rejection still logs a useful value
  • Regression test: CMS + Strapi + EP in one module → Fastly / customHost wins

Design decisions

Testing

  • Unit: existing extract tests + new shared-module regression
  • Manual: Studio project with Plasmic CMS + EP Provider (custom Fastly host) — storefront session mint no longer fails with data.plasmic.app allowlist / bootstrap 401

Reviewer notes

  • Independent of cart drawer designer-error work; no dependency on that PR
  • Affects consumers that use extractEpProviderConfig / buildEpCtx / resolveConfig from the Plasmic bundle
  • Apps that pass explicit clientId/host into createEpAuth and don’t rely on bundle extraction are unaffected

mzaintariq and others added 2 commits August 11, 2026 17:45
CMS/Strapi host defaults in the same module were winning first-match and breaking OAuth bootstrap; collect all host matches and favor custom+customHost.
Group clientId / host / customHost / serverCartMode by the props identifier
codegen binds per global context, so a module nesting CMS, Strapi or another
commerce provider alongside EP can no longer contribute one provider's field
to another's config. Restores the original custom-host resolution now that it
reads a single provider's props.

Allowlist rejections are collected and reported only when no candidate
resolves, so a project using a second commerce provider does not log an
allowlist error for that provider's host on a working storefront.
@mzaintariq
mzaintariq merged commit 2165cdd into master Aug 12, 2026
9 checks passed
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.

2 participants