From 19bb741af082310cb6b2d4c88e7d1e37958942a1 Mon Sep 17 00:00:00 2001 From: Ivan Pantic Date: Tue, 9 Dec 2025 22:12:45 +0100 Subject: [PATCH] Fix issue: Broken pasted image upload --- server/index.js | 6 +++--- src/utils/api.js | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/server/index.js b/server/index.js index a094d9d..743ba41 100755 --- a/server/index.js +++ b/server/index.js @@ -447,7 +447,7 @@ app.post('/api/projects/create', authenticateToken, async (req, res) => { }); // Browse filesystem endpoint for project suggestions - uses existing getFileTree -app.get('/api/browse-filesystem', authenticateToken, async (req, res) => { +app.get('/api/browse-filesystem', authenticateToken, async (req, res) => { try { const { path: dirPath } = req.query; @@ -495,9 +495,9 @@ app.get('/api/browse-filesystem', authenticateToken, async (req, res) => { suggestions.push(...directories); } - res.json({ + res.json({ path: targetPath, - suggestions: suggestions + suggestions: suggestions }); } catch (error) { diff --git a/src/utils/api.js b/src/utils/api.js index f0b8e6f..d2ffb8c 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -3,9 +3,12 @@ export const authenticatedFetch = (url, options = {}) => { const isPlatform = import.meta.env.VITE_IS_PLATFORM === 'true'; const token = localStorage.getItem('auth-token'); - const defaultHeaders = { - 'Content-Type': 'application/json', - }; + const defaultHeaders = {}; + + // Only set Content-Type if body is not FormData (browser will set it automatically for FormData) + if (!(options.body instanceof FormData)) { + defaultHeaders['Content-Type'] = 'application/json'; + } if (!isPlatform && token) { defaultHeaders['Authorization'] = `Bearer ${token}`;