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:
@@ -2,10 +2,10 @@ const express = require('express');
|
||||
const bcrypt = require('bcryptjs');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const { SERVER_DIR } = require('../server');
|
||||
|
||||
const router = express.Router();
|
||||
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() {
|
||||
await fs.ensureDir(path.dirname(USERS_FILE));
|
||||
|
||||
@@ -2,9 +2,9 @@ const express = require('express');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const { exec } = require('child_process');
|
||||
const { SERVER_DIR } = require('../server');
|
||||
|
||||
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) {
|
||||
if (req.session.user) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const express = require('express');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const { SERVER_DIR } = require('../server');
|
||||
|
||||
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) {
|
||||
if (req.session.user) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const express = require('express');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const { SERVER_DIR } = require('../server');
|
||||
|
||||
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) {
|
||||
if (req.session.user) {
|
||||
|
||||
@@ -2,9 +2,9 @@ const express = require('express');
|
||||
const RconClient = require('../utils/rcon');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const { SERVER_DIR } = require('../server');
|
||||
|
||||
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) {
|
||||
if (req.session.user) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const express = require('express');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const { SERVER_DIR } = require('../server');
|
||||
|
||||
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) {
|
||||
if (req.session.user) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const express = require('express');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const { SERVER_DIR } = require('../server');
|
||||
|
||||
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) {
|
||||
if (req.session.user) {
|
||||
|
||||
@@ -54,11 +54,24 @@ app.get('/api/health', (req, res) => {
|
||||
res.json({ status: 'ok', timestamp: new Date() });
|
||||
});
|
||||
|
||||
// Erreur 404
|
||||
app.use((req, res) => {
|
||||
// Servir les fichiers statiques du frontend
|
||||
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' });
|
||||
});
|
||||
|
||||
// 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
|
||||
app.use((err, req, res, next) => {
|
||||
console.error(err);
|
||||
|
||||
Reference in New Issue
Block a user