fix(cleanup): TODO-006 — centralize backend URL via getBackendBaseURL() from product-config

This commit is contained in:
saravanakumardb1 2026-04-13 14:58:44 -07:00
parent d74c80a711
commit 5dafcc2118

View File

@ -2,6 +2,8 @@
// Keyword → helpful prep message mapping. Expandable, no LLM needed. // Keyword → helpful prep message mapping. Expandable, no LLM needed.
// Used in notification body and on timeline to give actionable context. // Used in notification body and on timeline to give actionable context.
import { getBackendBaseURL } from './product-config';
export interface ContextRule { export interface ContextRule {
keywords: string[]; keywords: string[];
messages: string[]; messages: string[];
@ -192,15 +194,8 @@ export async function fetchEnrichedMessage(params: {
timeOfDay?: string; timeOfDay?: string;
recentTimerLabels?: string[]; recentTimerLabels?: string[];
}): Promise<EnrichedMessageResult> { }): Promise<EnrichedMessageResult> {
// TODO-006: Centralize backend URL configuration
// Priority: low | Phase: A.4
// Replace the raw env var with a centralized config helper. Options:
// 1. Create getBackendUrl() in web/src/lib/product-config.ts that reads
// NEXT_PUBLIC_CHRONOMIND_BACKEND_URL with a sensible default
// 2. Or use the same pattern as auth-api.ts getBaseUrl() but for the product backend
// This avoids scattering env var references across multiple files.
try { try {
const backendUrl = process.env.NEXT_PUBLIC_CHRONOMIND_BACKEND_URL ?? 'http://localhost:4011'; const backendUrl = getBackendBaseURL();
const res = await fetch(`${backendUrl}/api/context-message`, { const res = await fetch(`${backendUrl}/api/context-message`, {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },