Skip to content

fix(shopify): OAuth redirected to localhost in prod; default SELF_URL + MESH_URL override - #528

Merged
guitavano merged 2 commits into
mainfrom
guitavano/shopify-oauth-selfurl-fix
Jul 28, 2026
Merged

fix(shopify): OAuth redirected to localhost in prod; default SELF_URL + MESH_URL override#528
guitavano merged 2 commits into
mainfrom
guitavano/shopify-oauth-selfurl-fix

Conversation

@guitavano

@guitavano guitavano commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #526. Two prod-breaking bugs found after deploy, both in how OAuth URLs/origins were resolved.

Bug 1 — Authorize sent merchants to localhost

SELF_URL defaulted to http://localhost:8000, so with the env unset in prod authorizationUrl built http://localhost:8000/oauth/custom.
Fix: default SELF_URL to the deployed origin https://sites-shopify.deco.site (override via env for local dev). Mirrors the SERVER_PUBLIC_URL convention in the microsoft-teams MCP.

Bug 2 — "Invalid or missing callback URL"

The runtime mounts its /oauth/callback on this MCP's own origin, so the callback_url handed to authorizationUrl is on sites-shopify.deco.site, not decocms.com. The decocms-only allowlist rejected it.
Fix: accept the SELF_URL origin as the primary allowed callback origin.

Callback allowlist (anti-open-redirect)

Allowed callback origins now: the MCP's own origin (SELF_URL), decocms.com (+ subdomains), loopback over http (dev), and an optional operator-set MESH_URL override for a self-hosted / local deco studio on a custom origin.

Tests

bun test54 pass, incl.: SELF_URL unset → prod domain (not localhost); callback on the MCP's own origin accepted; off-origin rejected; MESH_URL whitelists a custom origin. tsc clean.

🤖 Generated with Claude Code

guitavano and others added 2 commits July 28, 2026 13:12
SELF_URL defaulted to http://localhost:8000, so with the env var unset in
production authorizationUrl built http://localhost:8000/oauth/custom and sent
merchants to their own machine. The MCP is deployed at a fixed domain, so
default SELF_URL to https://sites-shopify.deco.site (override via env for local
dev) — mirrors the SERVER_PUBLIC_URL convention in the microsoft-teams MCP.

Also drop the MESH_URL dependency: validate the OAuth callback against a
decocms.com host-suffix allowlist (+ loopback for dev), the same model as the
GitHub MCP, so the mesh origin no longer needs to be configured.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Optional operator-set override on top of the decocms.com/loopback allowlist,
so a local deco studio on a custom origin can complete the OAuth callback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@guitavano
guitavano merged commit 51aaa13 into main Jul 28, 2026
2 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.

1 participant