File tree Expand file tree Collapse file tree 2 files changed +21
-7
lines changed
app/src/cli/utilities/app
cli-kit/src/public/node/context Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 1- import { normalizeStoreFqdn } from '@shopify/cli-kit/node/context/fqdn'
1+ import { normalizeStoreFqdn , storeAdminUrl } from '@shopify/cli-kit/node/context/fqdn'
22
33export function buildAppURLForWeb ( storeFqdn : string , apiKey : string ) {
44 const normalizedFQDN = normalizeStoreFqdn ( storeFqdn )
5- return `https://${ normalizedFQDN } /admin/oauth/redirect_from_cli?client_id=${ apiKey } `
5+ const adminUrl = storeAdminUrl ( normalizedFQDN )
6+ return `https://${ adminUrl } /admin/oauth/redirect_from_cli?client_id=${ apiKey } `
67}
78
89export function buildAppURLForMobile ( storeFqdn : string , apiKey : string ) {
910 const normalizedFQDN = normalizeStoreFqdn ( storeFqdn )
10- const hostUrl = `${ normalizedFQDN } /admin/apps/${ apiKey } `
11+ const adminUrl = storeAdminUrl ( normalizedFQDN )
12+ const hostUrl = `${ adminUrl } /admin/apps/${ apiKey } `
1113 const hostParam = Buffer . from ( hostUrl ) . toString ( 'base64' ) . replace ( / [ = ] / g, '' )
1214 return `https://${ hostUrl } ?shop=${ normalizedFQDN } &host=${ hostParam } `
1315}
Original file line number Diff line number Diff line change @@ -139,8 +139,20 @@ export function normalizeStoreFqdn(store: string): string {
139139 }
140140 const containDomain = ( storeFqdn : string ) =>
141141 storeFqdn . endsWith ( '.myshopify.com' ) || storeFqdn . endsWith ( 'shopify.io' ) || storeFqdn . endsWith ( '.shop.dev' )
142- const normalizedFqdn = containDomain ( storeFqdn ) ? storeFqdn : addDomain ( storeFqdn )
143- // Use dev-api domain for OAuth redirects in local environment
144- // See: https://github.com/Shopify/dev_server?tab=readme-ov-file#shop-redirects
145- return normalizedFqdn . replace ( '.my.shop.dev' , '.dev-api.shop.dev' )
142+ return containDomain ( storeFqdn ) ? storeFqdn : addDomain ( storeFqdn )
143+ }
144+
145+ /**
146+ * Convert a store FQDN to the admin URL pattern for local development.
147+ * In local mode, transforms \{store\}.my.shop.dev to admin.shop.dev/store/\{store\}.
148+ *
149+ * @param storeFqdn - Normalized store FQDN.
150+ * @returns Store admin URL base (without protocol or path).
151+ */
152+ export function storeAdminUrl ( storeFqdn : string ) : string {
153+ if ( serviceEnvironment ( ) === 'local' && storeFqdn . endsWith ( '.my.shop.dev' ) ) {
154+ const storeName = storeFqdn . replace ( '.my.shop.dev' , '' )
155+ return `admin.shop.dev/store/${ storeName } `
156+ }
157+ return storeFqdn
146158}
You can’t perform that action at this time.
0 commit comments