diff --git a/src/services/aiAnalysis.ts b/src/services/aiAnalysis.ts index 5326d5d..c4965df 100644 --- a/src/services/aiAnalysis.ts +++ b/src/services/aiAnalysis.ts @@ -17,9 +17,11 @@ export async function analyzeFeatureWithAI( try { // Prefer dedicated analysis endpoint if available in requirements service const primaryUrl = `${BACKEND_URL}/api/requirements/analyze-feature` + const accessToken = (typeof window !== 'undefined') ? localStorage.getItem('accessToken') : null + const authHeaders = accessToken ? { Authorization: `Bearer ${accessToken}` } : {} let res = await fetch(primaryUrl, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...authHeaders }, body: JSON.stringify({ featureName, description, requirements, projectType, complexity: userSelectedComplexity }), }) @@ -28,7 +30,7 @@ export async function analyzeFeatureWithAI( const fallbackUrl = `${BACKEND_URL}/api/mockup/generate-wireframe` res = await fetch(fallbackUrl, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...authHeaders }, body: JSON.stringify({ prompt: `${featureName}: ${description}. Requirements: ${requirements.join('; ')}`, device: 'desktop',