diff --git a/static/shared/js/api-client.js b/static/shared/js/api-client.js index 31ed6703..5ff71ac6 100644 --- a/static/shared/js/api-client.js +++ b/static/shared/js/api-client.js @@ -37,7 +37,8 @@ class APIClient { * Uses path-based detection to return the correct token: * - /admin/* routes use admin_token * - /store/* routes use store_token - * - /shop/* routes use customer_token + * - /account/* or /api/v1/storefront/* routes use customer_token + * - /merchants/* routes use merchant_token * - Other routes fall back to admin_token || store_token || customer_token */ getToken() { @@ -58,9 +59,7 @@ class APIClient { source = 'admin (path-based)'; } else if ( currentPath.startsWith('/account/') || - currentPath.startsWith('/api/v1/storefront/') || - currentPath.includes('/shop/') || - currentPath.startsWith('/api/v1/shop/') + currentPath.startsWith('/api/v1/storefront/') ) { token = customerToken; source = 'customer (path-based)'; @@ -374,7 +373,8 @@ class APIClient { * Uses path-based detection to clear only the relevant token: * - /admin/* paths clear admin_token * - /store/* paths clear store_token - * - /shop/* paths clear customer_token + * - /account/* or /api/v1/storefront/* paths clear customer_token + * - /merchants/* paths clear merchant_token * - Other paths clear all tokens (fallback) */ clearTokens() { @@ -405,9 +405,7 @@ class APIClient { localStorage.removeItem('storeCode'); } else if ( currentPath.startsWith('/account/') || - currentPath.startsWith('/api/v1/storefront/') || - currentPath.includes('/shop/') || - currentPath.startsWith('/api/v1/shop/') + currentPath.startsWith('/api/v1/storefront/') ) { apiLog.info('Clearing customer tokens only'); localStorage.removeItem('customer_token');