PrestaGhis commited on
Commit
fc71440
·
verified ·
1 Parent(s): 5946873

Update components/content/ContentAnalysisLauncher.tsx

Browse files
components/content/ContentAnalysisLauncher.tsx CHANGED
@@ -192,11 +192,10 @@ export default function ContentAnalysisLauncher({ onComplete }: ContentAnalysisL
192
  setSubmitError(null)
193
 
194
  try {
195
- // Lit le token directement depuis localStorage sans créer de client Supabase
196
- const storageKey = Object.keys(localStorage).find(k => k.includes('auth-token'))
197
- const authData = storageKey ? JSON.parse(localStorage.getItem(storageKey) || '{}') : {}
198
- const token = authData?.access_token || ''
199
-
200
  const res = await fetch('/api/content/analyze', {
201
  method: 'POST',
202
  headers: {
@@ -209,7 +208,9 @@ export default function ContentAnalysisLauncher({ onComplete }: ContentAnalysisL
209
  mode,
210
  url: url.trim() || undefined,
211
  veille_brief: veilleBrief,
212
- veille_project_id: veilleProjectId
 
 
213
  }),
214
  })
215
 
 
192
  setSubmitError(null)
193
 
194
  try {
195
+ // 🚀 Correction : Récupération du token via Supabase (plus robuste que le localStorage manuel)
196
+ const { data: { session } } = await supabase.auth.getSession()
197
+ const token = session?.access_token || ''
198
+
 
199
  const res = await fetch('/api/content/analyze', {
200
  method: 'POST',
201
  headers: {
 
208
  mode,
209
  url: url.trim() || undefined,
210
  veille_brief: veilleBrief,
211
+ veille_project_id: veilleProjectId,
212
+ // 🚀 Support de l'impersonation (admin agissant pour un client)
213
+ impersonated_client_id: localStorage.getItem('impersonated_client_id')
214
  }),
215
  })
216