diff --git a/storefront/lib/medusa-client.ts b/storefront/lib/medusa-client.ts new file mode 100644 index 0000000..ea5ba96 --- /dev/null +++ b/storefront/lib/medusa-client.ts @@ -0,0 +1,16 @@ +import Medusa from '@medusajs/medusa-js'; + +const MEDUSA_SERVER_URL = process.env.NEXT_PUBLIC_MEDUSA_SERVER_URL; + +const createMedusaClient = () => { + if (!MEDUSA_SERVER_URL) { + throw new Error('Missing Medusa server URL'); + } + + return new Medusa({ + maxRetries: 3, + baseUrl: MEDUSA_SERVER_URL, + }); +}; + +export const medusaClient = createMedusaClient();