The backend functions weren't working in the Electron app because the environment detection was happening at module load time instead of runtime. This caused the app to try making HTTP requests to localhost:3003 even when running as a desktop app.
Changed isElectron from a static property to a getter function in frontend/src/utils/unifiedAPI.js:
// ❌ Before (wrong):
export const api = {
isElectron: isElectron(), // Evaluated once at module load
// ...
}
// ✅ After (correct):
export const api = {
get isElectron() { // Evaluated dynamically at runtime
return isElectron();
},
// ...
}npm run build:frontend
npm run electron- Open the Electron app
- Navigate to "GIF Maker"
- Add 2-3 images
- Click "Create GIF"
- Open DevTools (Ctrl+Shift+I or Cmd+Option+I)
You should see:
🎬 Creating GIF from 3 images
📱 Running in Electron: true
🔧 window.electronAPI available: true
📱 Using Electron IPC for GIF creation
💾 Saving temp file 1/3: image1.jpg
💾 Saving temp file 2/3: image2.jpg
💾 Saving temp file 3/3: image3.jpg
✅ GIF created successfully via Electron
Should be empty - no HTTP requests to localhost:3003!
- All processing happens locally via IPC
- Uses Sharp, FFmpeg, and Canvas directly in main process
- No backend server needed
- 100% offline capable
- Fast and private
- Processing via HTTP API to backend server
- Backend must be running on localhost:3003
- Works for web deployments
Frontend (React)
│
├─── unifiedAPI.js
│ └─── if (isElectron()) → Electron IPC
│ └─── else → HTTP Fetch
│
├─── Electron Mode: window.electronAPI.createGifFromImages()
│ └─── Electron Main Process (main.js)
│ └─── Sharp + GIF Encoder
│
└─── Browser Mode: fetch('http://localhost:3003/api/...')
└─── Backend Server (Express)
└─── Sharp + FFmpeg
- ✅
frontend/src/utils/unifiedAPI.js- Fixed dynamic Electron detection - 📝
ELECTRON_BACKEND_FIX.md- Full technical documentation - 🧪
test-electron-integration.js- Testing checklist
All these components now work correctly in both Electron and browser mode:
- ✅ ImageGifMaker
- ✅ VideoToGifConverter
- ✅ WebPConverter
- ✅ GifSplitter
- ✅ MainConversionInterface
- ✅ ModernFormatTool
- ✅ And more...
- Check DevTools console for error messages
- Verify Sharp is installed:
npm list sharp - Check temp directory exists:
c:\MyPersonelProjects\AIO converter\temp - Rebuild frontend:
npm run build:frontend
- Clear browser cache
- Rebuild frontend:
npm run build:frontend - Restart Electron app
- Check that
window.electronAPIis defined (console:window.electronAPI)
- Console shows "📱 Using Electron IPC for..."
- Network tab empty (no HTTP requests)
- GIF created and displayed successfully
- No errors in console
- File saved to temp directory
- Full technical details:
ELECTRON_BACKEND_FIX.md - Electron main process:
electron/main.js - Preload script:
electron/preload.js - API client:
frontend/src/utils/unifiedAPI.js