Skip to content

Conversation

@weslleyaraujo
Copy link

@weslleyaraujo weslleyaraujo commented Dec 10, 2025

Problem

Currently, multiple Shopify apps patch @shopify/shopify-api to enable local core development with split domain architecture. This creates maintenance burden and requires coordination across teams when the library changes.

Slack discussion

Affected apps:

This PR introduces a proposal to solve this problem by adding a new domainTransformations configuration option that allows apps to define domain mappings without patching the library.

interface DomainTransformation {
  // Pattern to match source domain
  match: RegExp | string;

  // Transformation: function or template string
  transform: ((matches: RegExpMatchArray) => string | null) | string;

  // Whether to include in host validation (default: true)
  includeHost?: boolean;
}

Template-based transformation (simple):

import { shopifyApi } from "@shopify/shopify-api";

const shopify = shopifyApi({
  // ... other config ...
  domainTransformations: [
    {
      match: /^([a-zA-Z0-9][a-zA-Z0-9-_]*)\.my\.shop\.dev$/,
      transform: "$1.dev-api.shop.dev",
    },
  ],
});

Function-based transformation:

const shopify = shopifyApi({
  // ... other config ...
  domainTransformations: [
    {
      match: /^([a-zA-Z0-9-_]+)\.admin\.example\.com$/,
      transform: (matches) => {
        const shopName = matches[1];
        return shopName.startsWith("test-")
          ? `${shopName}.api-staging.example.com`
          : `${shopName}.api.example.com`;
      },
    },
  ],
});

For the affected apps, it would look like this:

// app/shopify.server.ts
import { shopifyApp } from "@shopify/shopify-app-remix/server";

const shopify = shopifyApp({
  apiKey: process.env.SHOPIFY_API_KEY!,
  apiSecretKey: process.env.SHOPIFY_API_SECRET!,
  domainTransformations: isDevelopment
    ? [
        {
          match: /^([a-zA-Z0-9][a-zA-Z0-9-_]*)\.my\.shop\.dev$/,
          transform: "$1.dev-api.shop.dev",
        },
      ]
    : undefined,
});

Demo

Here is an example of the bundles app running locally with a custom build version of this PR:
Screenshot 2025-12-10 at 14 33 03

PS: shopify-app-remix is also linked here, but is unrelated. Bundles has an outdated version, which is not compatible with the current shopify-app library.

Resources

@weslleyaraujo weslleyaraujo requested a review from a team as a code owner December 10, 2025 12:15
@weslleyaraujo weslleyaraujo force-pushed the Add_domain_transformation_support_for_split-domain_architectures branch 3 times, most recently from 6287105 to b09b351 Compare December 10, 2025 12:37
@weslleyaraujo weslleyaraujo changed the title Add Domain Transformations Support for Split-Domain Architectures Implement domain transformations support for split-domain architectures Dec 10, 2025
@weslleyaraujo weslleyaraujo marked this pull request as draft December 10, 2025 14:04
@weslleyaraujo weslleyaraujo marked this pull request as ready for review December 10, 2025 14:04
@weslleyaraujo weslleyaraujo marked this pull request as draft December 10, 2025 14:46
@weslleyaraujo weslleyaraujo force-pushed the Add_domain_transformation_support_for_split-domain_architectures branch 2 times, most recently from 1cd27dd to 8e6328c Compare December 10, 2025 15:30
@weslleyaraujo weslleyaraujo force-pushed the Add_domain_transformation_support_for_split-domain_architectures branch from 8e6328c to b92550b Compare December 10, 2025 15:47
@weslleyaraujo weslleyaraujo marked this pull request as ready for review December 10, 2025 15:56
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