diff --git a/client/src/App.tsx b/client/src/App.tsx index 0212d45..c38c974 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -2,7 +2,9 @@ import { useState, useEffect, useMemo } from 'react'; import axios from 'axios'; import { Key, Plus, Copy, CheckCircle, Clock, Search, Users, ChevronRight, ArrowLeft, Trash2 } from 'lucide-react'; -const API_BASE = 'http://localhost:3006/api'; +const API_BASE = import.meta.env.DEV + ? 'http://localhost:3006/api' + : '/api'; interface License { id: number; diff --git a/server/server.js b/server/server.js index 60da100..9345178 100644 --- a/server/server.js +++ b/server/server.js @@ -109,6 +109,22 @@ app.post('/api/licenses/generate', async (req, res) => { } }); +// Serve Static Files (Production) +const clientDistPath = path.join(__dirname, '../client/dist'); +if (fs.existsSync(clientDistPath)) { + app.use(express.static(clientDistPath)); + + // SPA Fallback: Any route not handled by API should return index.html + app.get('*', (req, res) => { + if (!req.path.startsWith('/api')) { + res.sendFile(path.join(clientDistPath, 'index.html')); + } + }); + console.log(`📁 Serving client from ${clientDistPath}`); +} else { + console.log('⚠️ Client dist folder not found. API mode only.'); +} + app.listen(PORT, () => { console.log(`🚀 License Manager Server running on port ${PORT}`); });