Chore: Prepare for Synology NAS deployment (Serve static client, dynamic API_BASE)
This commit is contained in:
parent
f639192d1c
commit
1fb9a33776
@ -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;
|
||||
|
||||
@ -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}`);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user