Fix: Ajouter Authorization header aux requêtes fetch du scan
Problème: Les requêtes fetch() vers /api/library/scan utilisaient pas l'interceptor axios, donc le token JWT n'était pas envoyé. Résultat: 403 Forbidden Solution: Ajouter manuellement le header Authorization avec le token depuis localStorage pour les requêtes fetch du rescan. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -91,8 +91,17 @@ export default function Home() {
|
||||
setIsScanning(true)
|
||||
setScanStatus("Démarrage du scan...")
|
||||
|
||||
const token = localStorage.getItem('access_token')
|
||||
const headers: HeadersInit = {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`
|
||||
}
|
||||
|
||||
const response = await fetch(`${getApiUrl()}/api/library/scan`, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -104,7 +113,9 @@ export default function Home() {
|
||||
// Poll scan status
|
||||
const pollInterval = setInterval(async () => {
|
||||
try {
|
||||
const statusResponse = await fetch(`${getApiUrl()}/api/library/scan/status`)
|
||||
const statusResponse = await fetch(`${getApiUrl()}/api/library/scan/status`, {
|
||||
headers,
|
||||
})
|
||||
const status = await statusResponse.json()
|
||||
|
||||
if (!status.is_scanning) {
|
||||
|
||||
Reference in New Issue
Block a user