fix: routes API accessibles sous /api en production

- Création d'un apiRouter Express pour toutes les routes API
- Routes montées sous /api ET à la racine (rétrocompatibilité)
- QR code corrigé : HTTPS en mode production
- start.sh : affichage URL HTTPS corrigé
- Résout le problème de connexion en mode production
This commit is contained in:
2026-05-27 22:31:41 +02:00
parent 70fc1e833d
commit e84ed7c731
5 changed files with 17 additions and 9 deletions
+1 -1
View File
@@ -81,7 +81,7 @@ define(['./workbox-290dd570'], (function (workbox) { 'use strict';
"revision": "3ca0b8505b4bec776b69afdba2768812" "revision": "3ca0b8505b4bec776b69afdba2768812"
}, { }, {
"url": "index.html", "url": "index.html",
"revision": "0.spc2v3301v8" "revision": "0.lhgefe7plc8"
}], {}); }], {});
workbox.cleanupOutdatedCaches(); workbox.cleanupOutdatedCaches();
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
File diff suppressed because one or more lines are too long
+11 -4
View File
@@ -221,11 +221,14 @@ app.use('/admin', adminRouter);
// ========== Routes API ========== // ========== Routes API ==========
// Créer un router pour les routes API
const apiRouter = express.Router();
/** /**
* GET /config * GET /config
* Retourne la configuration des groupes * Retourne la configuration des groupes
*/ */
app.get('/config', (req, res) => { apiRouter.get('/config', (req, res) => {
try { try {
const clientConfig = { const clientConfig = {
groups: config.groups.map(g => ({ groups: config.groups.map(g => ({
@@ -249,7 +252,7 @@ app.get('/config', (req, res) => {
* GET /groups * GET /groups
* Retourne la liste des groupes disponibles (simplifié) * Retourne la liste des groupes disponibles (simplifié)
*/ */
app.get('/groups', (req, res) => { apiRouter.get('/groups', (req, res) => {
try { try {
const groups = config.groups.map(g => ({ const groups = config.groups.map(g => ({
id: g.id, id: g.id,
@@ -268,7 +271,7 @@ app.get('/groups', (req, res) => {
* Génère un token LiveKit pour un client * Génère un token LiveKit pour un client
* Body: { username: string, groupId: string } * Body: { username: string, groupId: string }
*/ */
app.post('/token', async (req, res) => { apiRouter.post('/token', async (req, res) => {
try { try {
const { username, groupId } = req.body; const { username, groupId } = req.body;
@@ -347,7 +350,7 @@ app.post('/token', async (req, res) => {
* GET /health * GET /health
* Health check * Health check
*/ */
app.get('/health', (req, res) => { apiRouter.get('/health', (req, res) => {
const isLivekitRunning = livekitProcess !== null; const isLivekitRunning = livekitProcess !== null;
res.json({ res.json({
status: isLivekitRunning ? 'ok' : 'degraded', status: isLivekitRunning ? 'ok' : 'degraded',
@@ -356,6 +359,10 @@ app.get('/health', (req, res) => {
}); });
}); });
// Monter le router API sous /api ET à la racine (rétrocompatibilité)
app.use('/api', apiRouter);
app.use(apiRouter); // Routes accessibles aussi sans préfixe /api
/** /**
* GET / * GET /
* Info serveur OU client PWA (si build existe) * Info serveur OU client PWA (si build existe)
+3 -3
View File
@@ -27,11 +27,11 @@ NETWORK_IP=$(get_network_ip)
# Déterminer l'URL selon mode dev ou prod # Déterminer l'URL selon mode dev ou prod
if [ -d "client/dist" ] && [ "$1" != "--dev" ]; then if [ -d "client/dist" ] && [ "$1" != "--dev" ]; then
# Mode production # Mode production (HTTPS)
URL="http://${NETWORK_IP}:3000" URL="https://${NETWORK_IP}:3000"
MODE="production" MODE="production"
else else
# Mode dev # Mode dev (HTTPS)
URL="https://${NETWORK_IP}:5173" URL="https://${NETWORK_IP}:5173"
MODE="dev" MODE="dev"
fi fi
+1
View File
@@ -192,6 +192,7 @@ else
echo -e "${YELLOW} (Cliquez sur 'Avancé' puis 'Continuer')${NC}" echo -e "${YELLOW} (Cliquez sur 'Avancé' puis 'Continuer')${NC}"
echo "" echo ""
echo "🎛️ Interface admin : https://localhost:3000/admin" echo "🎛️ Interface admin : https://localhost:3000/admin"
echo "📊 API serveur : https://localhost:3000/api"
echo "" echo ""
echo "📝 Logs serveur : tail -f server.log" echo "📝 Logs serveur : tail -f server.log"
echo "" echo ""