diff --git a/.changeset/plenty-bikes-confess.md b/.changeset/plenty-bikes-confess.md new file mode 100644 index 0000000000..06be78821c --- /dev/null +++ b/.changeset/plenty-bikes-confess.md @@ -0,0 +1,5 @@ +--- +'@shopify/hydrogen-react': patch +--- + +Skip private access token warning when using mock.shop. diff --git a/package-lock.json b/package-lock.json index f3e5db5253..91ae349b13 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,7 @@ "requires": true, "packages": { "": { + "name": "hydrogen", "workspaces": [ "templates/hello-world", "templates/demo-store", diff --git a/package.json b/package.json index fe9ad01b07..03a028fc35 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,5 @@ { + "name": "hydrogen", "private": true, "sideEffects": false, "scripts": { diff --git a/packages/hydrogen-react/src/storefront-client.ts b/packages/hydrogen-react/src/storefront-client.ts index 64b60b294d..3a75fdee0c 100644 --- a/packages/hydrogen-react/src/storefront-client.ts +++ b/packages/hydrogen-react/src/storefront-client.ts @@ -17,6 +17,8 @@ export type StorefrontClientProps = { contentType?: 'json' | 'graphql'; }; +const isMockShop = (domain: string): boolean => domain.includes('mock.shop'); + /** * The `createStorefrontClient()` function creates helpers that enable you to quickly query the Shopify Storefront API. * @@ -48,7 +50,12 @@ export function createStorefrontClient( } // only warn if not in a browser environment - if (__HYDROGEN_DEV__ && !privateStorefrontToken && !globalThis.document) { + if ( + __HYDROGEN_DEV__ && + !privateStorefrontToken && + !globalThis.document && + !isMockShop(storeDomain) + ) { warnOnce( `Using a private storefront token is recommended for server environments.` + `\nRefer to the authentication https://shopify.dev/api/storefront#authentication documentation for more details.`, @@ -63,7 +70,6 @@ export function createStorefrontClient( ); } - const isMockShop = (domain: string): boolean => domain.includes('mock.shop'); const getShopifyDomain: StorefrontClientReturn['getShopifyDomain'] = ( overrideProps, ) => {