Skip to content

Commit 2e23cff

Browse files
committed
refactor(cache): Simplify production app URL determination and update log message
1 parent bb103f7 commit 2e23cff

1 file changed

Lines changed: 2 additions & 14 deletions

File tree

src/lib/server/cache-coordination.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,7 @@ import { env } from '$env/dynamic/private';
66

77
const CACHE_API_KEY = env.CACHE_INVALIDATION_API_KEY || 'your-secret-key';
88

9-
// Determine the production app URL based on environment
10-
const getProductionAppUrl = (): string => {
11-
// If explicitly set in environment, use that
12-
if (env.PUBLIC_STORE_URL) {
13-
return env.PUBLIC_STORE_URL;
14-
}
15-
16-
// Auto-detect based on environment
17-
const isDocker = env.NODE_ENV === 'production' || env.HOST === '0.0.0.0';
18-
return isDocker ? 'http://hotelhunger-app:3000' : 'http://localhost:3000';
19-
};
20-
21-
const PRODUCTION_APP_URL = getProductionAppUrl();
9+
const PRODUCTION_APP_URL = env.STORE_FRONT_URL || 'http://localhost:3000';
2210

2311
interface CacheInvalidationRequest {
2412
type: 'product' | 'category' | 'all';
@@ -40,7 +28,7 @@ export async function invalidateProductionCache(
4028
apiKey: CACHE_API_KEY
4129
};
4230

43-
console.log(`[Cache Coordination] Targeting hotelhunger-app: ${PRODUCTION_APP_URL}`);
31+
console.log(`[Cache Coordination] Targeting storefront app: ${PRODUCTION_APP_URL}`);
4432
console.log(`[Cache Coordination] Sending cache invalidation request: type=${type}, id=${id}`);
4533

4634
const response = await fetch(`${PRODUCTION_APP_URL}/api/cache/invalidate`, {

0 commit comments

Comments
 (0)