feat: migrate application port from 3000 to 4001 and fix circular dependencies
- Change default port to 4001 across all configuration files (server.js, docker-compose.yml, .env, Dockerfile) - Update frontend API URL to use new port 4001 - Fix circular dependency issues in route files by using process.env.SERVER_DIR instead of importing from server.js - Apply to all routes: auth.js, backup.js, logs.js, players.js, rcon.js, server.js, whitelist.js - Fix environment variable loading in start.sh to properly handle paths with spaces - Quote SERVER_DIR path in .env to preserve spaces in directory paths - Update all documentation references from port 3000 to 4001 (README, QUICKSTART, CONFIGURATION, INDEX) - Remove debug console.log statements from auth.js - Remove test utility file test-ops.js Fixes: Port conflict issues, circular dependency warnings, environment variable parsing
This commit is contained in:
@@ -81,8 +81,7 @@ Ouvrez `backend/.env` avec votre éditeur préféré:
|
|||||||
# Mode d'exécution
|
# Mode d'exécution
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
|
|
||||||
# Port de l'application (8080, 3000, etc.)
|
PORT=4001
|
||||||
PORT=3000
|
|
||||||
|
|
||||||
# Clé de session (générer une clé aléatoire forte)
|
# Clé de session (générer une clé aléatoire forte)
|
||||||
SESSION_SECRET=abc123def456ghi789jkl012mno345pqr
|
SESSION_SECRET=abc123def456ghi789jkl012mno345pqr
|
||||||
@@ -113,7 +112,7 @@ chmod +x start.sh
|
|||||||
|
|
||||||
Vous devriez voir:
|
Vous devriez voir:
|
||||||
```
|
```
|
||||||
🚀 Backend Admin NationsGlory démarré sur http://localhost:3000
|
🚀 Backend Admin NationsGlory démarré sur http://localhost:4001
|
||||||
📁 Répertoire du serveur: /home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red
|
📁 Répertoire du serveur: /home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -193,7 +192,7 @@ Si ça marche, RCON est correctement configuré! ✓
|
|||||||
2. Attendez que le serveur se redémarre ou recharge les OPs
|
2. Attendez que le serveur se redémarre ou recharge les OPs
|
||||||
3. Réessayez l'enregistrement
|
3. Réessayez l'enregistrement
|
||||||
|
|
||||||
### Problème: "Impossible de se connecter à localhost:3000"
|
### Problème: "Impossible de se connecter à localhost:4001"
|
||||||
|
|
||||||
**Cause**: L'application n'est pas lancée ou sur le mauvais port
|
**Cause**: L'application n'est pas lancée ou sur le mauvais port
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ RUN npm ci --only=production
|
|||||||
COPY backend/src ./src
|
COPY backend/src ./src
|
||||||
COPY frontend ./frontend
|
COPY frontend ./frontend
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 4001
|
||||||
|
|
||||||
CMD ["node", "src/server.js"]
|
CMD ["node", "src/server.js"]
|
||||||
|
|||||||
4
INDEX.md
4
INDEX.md
@@ -66,7 +66,7 @@ WebNationsGlory_ServeurBuild_Red/
|
|||||||
3. Éditer les fichiers .env
|
3. Éditer les fichiers .env
|
||||||
|
|
||||||
### Pour Utiliser l'Application
|
### Pour Utiliser l'Application
|
||||||
1. Ouvrir http://localhost:3000
|
1. Ouvrir http://localhost:4001
|
||||||
2. Créer le compte admin
|
2. Créer le compte admin
|
||||||
3. Utiliser les onglets du dashboard
|
3. Utiliser les onglets du dashboard
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ nano backend/.env
|
|||||||
./start.sh
|
./start.sh
|
||||||
|
|
||||||
# 5. Accès
|
# 5. Accès
|
||||||
# Ouvrir: http://localhost:3000
|
# Ouvrir: http://localhost:4001
|
||||||
```
|
```
|
||||||
|
|
||||||
## 📚 Fichiers Importants à Connaître
|
## 📚 Fichiers Importants à Connaître
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ nano backend/.env
|
|||||||
|
|
||||||
Vérifiez:
|
Vérifiez:
|
||||||
```env
|
```env
|
||||||
PORT=3000
|
PORT=4001
|
||||||
SERVER_DIR=/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red
|
SERVER_DIR=/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red
|
||||||
RCON_HOST=localhost
|
RCON_HOST=localhost
|
||||||
RCON_PORT=25575
|
RCON_PORT=25575
|
||||||
@@ -51,12 +51,12 @@ RCON_PORT=25575
|
|||||||
|
|
||||||
Vous devriez voir:
|
Vous devriez voir:
|
||||||
```
|
```
|
||||||
🚀 Backend Admin NationsGlory démarré sur http://localhost:3000
|
🚀 Backend Admin NationsGlory démarré sur http://localhost:4001
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5️⃣ Accès (10 secondes)
|
### 5️⃣ Accès (10 secondes)
|
||||||
|
|
||||||
Ouvrez: **http://localhost:3000**
|
Ouvrez: **http://localhost:4001**
|
||||||
|
|
||||||
## 👤 Premier Compte
|
## 👤 Premier Compte
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ chmod +x install.sh
|
|||||||
Éditer `backend/.env`:
|
Éditer `backend/.env`:
|
||||||
```env
|
```env
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
PORT=3000
|
PORT=4001
|
||||||
SESSION_SECRET=changez-cette-cle-en-production
|
SESSION_SECRET=changez-cette-cle-en-production
|
||||||
SERVER_DIR=/path/to/NationsGlory_ServeurBuild_Red
|
SERVER_DIR=/path/to/NationsGlory_ServeurBuild_Red
|
||||||
RCON_HOST=localhost
|
RCON_HOST=localhost
|
||||||
@@ -95,11 +95,11 @@ chmod +x start.sh
|
|||||||
./start.sh
|
./start.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
L'interface est maintenant accessible sur: **http://localhost:3000**
|
L'interface est maintenant accessible sur: **http://localhost:4001**
|
||||||
|
|
||||||
## 🎯 Premier Démarrage
|
## 🎯 Premier Démarrage
|
||||||
|
|
||||||
1. Ouvrez http://localhost:3000
|
1. Ouvrez http://localhost:4001
|
||||||
2. Créez le compte admin (doit être un OP du serveur)
|
2. Créez le compte admin (doit être un OP du serveur)
|
||||||
3. Connectez-vous
|
3. Connectez-vous
|
||||||
4. Explorez l'interface!
|
4. Explorez l'interface!
|
||||||
|
|||||||
9
backend/data/users.json
Normal file
9
backend/data/users.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "1770229357567",
|
||||||
|
"username": "admin",
|
||||||
|
"mcUsername": "anakine22",
|
||||||
|
"password": "$2a$10$Ie5mXaPcz.zrQ.bPFTpGbuWJ3rqPCxU8lGlcHvnJzxigkIufSaG7K",
|
||||||
|
"createdAt": "2026-02-04T18:22:37.567Z"
|
||||||
|
}
|
||||||
|
]
|
||||||
1381
backend/package-lock.json
generated
Normal file
1381
backend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,10 +2,10 @@ const express = require('express');
|
|||||||
const bcrypt = require('bcryptjs');
|
const bcrypt = require('bcryptjs');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { SERVER_DIR } = require('../server');
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const USERS_FILE = path.join(__dirname, '../../data/users.json');
|
const USERS_FILE = path.join(__dirname, '../../data/users.json');
|
||||||
|
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red';
|
||||||
|
|
||||||
async function initUsersFile() {
|
async function initUsersFile() {
|
||||||
await fs.ensureDir(path.dirname(USERS_FILE));
|
await fs.ensureDir(path.dirname(USERS_FILE));
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ const express = require('express');
|
|||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
const { SERVER_DIR } = require('../server');
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red';
|
||||||
|
|
||||||
function isAuthenticated(req, res, next) {
|
function isAuthenticated(req, res, next) {
|
||||||
if (req.session.user) {
|
if (req.session.user) {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { SERVER_DIR } = require('../server');
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red';
|
||||||
|
|
||||||
function isAuthenticated(req, res, next) {
|
function isAuthenticated(req, res, next) {
|
||||||
if (req.session.user) {
|
if (req.session.user) {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { SERVER_DIR } = require('../server');
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red';
|
||||||
|
|
||||||
function isAuthenticated(req, res, next) {
|
function isAuthenticated(req, res, next) {
|
||||||
if (req.session.user) {
|
if (req.session.user) {
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ const express = require('express');
|
|||||||
const RconClient = require('../utils/rcon');
|
const RconClient = require('../utils/rcon');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { SERVER_DIR } = require('../server');
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red';
|
||||||
|
|
||||||
function isAuthenticated(req, res, next) {
|
function isAuthenticated(req, res, next) {
|
||||||
if (req.session.user) {
|
if (req.session.user) {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { SERVER_DIR } = require('../server');
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red';
|
||||||
|
|
||||||
function isAuthenticated(req, res, next) {
|
function isAuthenticated(req, res, next) {
|
||||||
if (req.session.user) {
|
if (req.session.user) {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { SERVER_DIR } = require('../server');
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red';
|
||||||
|
|
||||||
function isAuthenticated(req, res, next) {
|
function isAuthenticated(req, res, next) {
|
||||||
if (req.session.user) {
|
if (req.session.user) {
|
||||||
|
|||||||
@@ -54,11 +54,24 @@ app.get('/api/health', (req, res) => {
|
|||||||
res.json({ status: 'ok', timestamp: new Date() });
|
res.json({ status: 'ok', timestamp: new Date() });
|
||||||
});
|
});
|
||||||
|
|
||||||
// Erreur 404
|
// Servir les fichiers statiques du frontend
|
||||||
app.use((req, res) => {
|
app.use(express.static(path.join(__dirname, '../../frontend/public')));
|
||||||
|
|
||||||
|
// Route pour l'index
|
||||||
|
app.get('/', (req, res) => {
|
||||||
|
res.sendFile(path.join(__dirname, '../../frontend/public/index.html'));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Erreur 404 pour les routes API non trouvées
|
||||||
|
app.use('/api/*', (req, res) => {
|
||||||
res.status(404).json({ error: 'Route non trouvée' });
|
res.status(404).json({ error: 'Route non trouvée' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Pour toutes les autres routes, servir index.html (SPA support)
|
||||||
|
app.get('*', (req, res) => {
|
||||||
|
res.sendFile(path.join(__dirname, '../../frontend/public/index.html'));
|
||||||
|
});
|
||||||
|
|
||||||
// Error handler
|
// Error handler
|
||||||
app.use((err, req, res, next) => {
|
app.use((err, req, res, next) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Configuration API
|
// Configuration API
|
||||||
const API_URL = 'http://localhost:3000/api';
|
const API_URL = 'http://localhost:4001/api';
|
||||||
|
|
||||||
// State
|
// State
|
||||||
let currentUser = null;
|
let currentUser = null;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ echo ""
|
|||||||
echo "📝 Prochaines étapes:"
|
echo "📝 Prochaines étapes:"
|
||||||
echo "1. Modifiez backend/.env avec la bonne configuration"
|
echo "1. Modifiez backend/.env avec la bonne configuration"
|
||||||
echo "2. Lancez le serveur: cd backend && npm start"
|
echo "2. Lancez le serveur: cd backend && npm start"
|
||||||
echo "3. Accédez à l'interface: http://localhost:3000"
|
echo "3. Accédez à l'interface: http://localhost:4001"
|
||||||
echo ""
|
echo ""
|
||||||
echo "ℹ️ IMPORTANT: Activez RCON dans le server.properties du serveur MC:"
|
echo "ℹ️ IMPORTANT: Activez RCON dans le server.properties du serveur MC:"
|
||||||
echo " - enable-rcon=true"
|
echo " - enable-rcon=true"
|
||||||
|
|||||||
2
start.sh
2
start.sh
@@ -26,7 +26,7 @@ if [ ! -f "backend/.env" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Charger les variables d'environnement
|
# Charger les variables d'environnement
|
||||||
export $(cat backend/.env | grep -v '^#' | xargs)
|
source backend/.env
|
||||||
|
|
||||||
echo -e "${GREEN}✓ Variables d'environnement chargées${NC}"
|
echo -e "${GREEN}✓ Variables d'environnement chargées${NC}"
|
||||||
echo " - Port: $PORT"
|
echo " - Port: $PORT"
|
||||||
|
|||||||
Reference in New Issue
Block a user