From 817c2a1a595fdd65658a91c51935fbc6f9ad0d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Dvo=C5=99=C3=A1k?= <150935816+Dvorinka@users.noreply.github.com> Date: Mon, 26 May 2025 13:57:36 +0200 Subject: [PATCH] Add files via upload --- admin-dashboard.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/admin-dashboard.html b/admin-dashboard.html index e0d4102..3fa3c06 100644 --- a/admin-dashboard.html +++ b/admin-dashboard.html @@ -741,10 +741,21 @@ console.log(key, value); } + // Create a new headers object + const headers = new Headers(); + // Don't set Content-Type header manually when using FormData + // The browser will set it automatically with the correct boundary + + // Add Authorization header if token exists + const token = localStorage.getItem('token'); + if (token) { + headers.append('Authorization', `Bearer ${token}`); + } + const response = await fetch('/api/banner/update', { method: 'POST', + headers: headers, body: formData - // Don't set Content-Type header, let the browser set it with the correct boundary }); if (!response.ok) {