fix: corriger tous les chemins SERVER_DIR et RCON_HOST pour machine distante

- Remplacer fallback SERVER_DIR de '/home/innotex/Documents/...' à '/mc-server'
- Remplacer RCON_HOST de 'localhost' à '172.17.0.1' (Docker bridge gateway)
- 8 fichiers corrigés: server.js + 7 routes
- Localhost n'est pas accessible depuis Docker vers l'host
- 172.17.0.1 est la gateway Docker qui permet au container d'accéder l'host
This commit is contained in:
2026-02-05 02:17:04 +01:00
parent 75bbfe0a77
commit 8b905dc9b3
8 changed files with 10 additions and 10 deletions

View File

@@ -5,7 +5,7 @@ const path = require('path');
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'; const SERVER_DIR = process.env.SERVER_DIR || '/mc-server';
async function initUsersFile() { async function initUsersFile() {
await fs.ensureDir(path.dirname(USERS_FILE)); await fs.ensureDir(path.dirname(USERS_FILE));

View File

@@ -4,7 +4,7 @@ const path = require('path');
const { exec } = require('child_process'); const { exec } = require('child_process');
const router = express.Router(); const router = express.Router();
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red'; const SERVER_DIR = process.env.SERVER_DIR || '/mc-server';
function isAuthenticated(req, res, next) { function isAuthenticated(req, res, next) {
if (req.session.user) { if (req.session.user) {

View File

@@ -3,7 +3,7 @@ const fs = require('fs-extra');
const path = require('path'); const path = require('path');
const router = express.Router(); const router = express.Router();
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red'; const SERVER_DIR = process.env.SERVER_DIR || '/mc-server';
function isAuthenticated(req, res, next) { function isAuthenticated(req, res, next) {
if (req.session.user) { if (req.session.user) {

View File

@@ -3,7 +3,7 @@ const fs = require('fs-extra');
const path = require('path'); const path = require('path');
const router = express.Router(); const router = express.Router();
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red'; const SERVER_DIR = process.env.SERVER_DIR || '/mc-server';
function isAuthenticated(req, res, next) { function isAuthenticated(req, res, next) {
if (req.session && req.session.user) { if (req.session && req.session.user) {

View File

@@ -4,7 +4,7 @@ const fs = require('fs-extra');
const path = require('path'); const path = require('path');
const router = express.Router(); const router = express.Router();
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red'; const SERVER_DIR = process.env.SERVER_DIR || '/mc-server';
function isAuthenticated(req, res, next) { function isAuthenticated(req, res, next) {
if (req.session && req.session.user) { if (req.session && req.session.user) {
@@ -20,9 +20,9 @@ async function getRconConfig() {
const content = await fs.readFile(serverPropsFile, 'utf-8'); const content = await fs.readFile(serverPropsFile, 'utf-8');
const lines = content.split('\n'); const lines = content.split('\n');
// Utiliser RCON_HOST depuis les variables d'environnement ou localhost // Utiliser RCON_HOST depuis les variables d'environnement (172.17.0.1 = Docker bridge gateway)
let config = { let config = {
host: process.env.RCON_HOST || 'localhost', host: process.env.RCON_HOST || '172.17.0.1',
port: process.env.RCON_PORT || 25575, port: process.env.RCON_PORT || 25575,
password: '' password: ''
}; };

View File

@@ -3,7 +3,7 @@ const fs = require('fs-extra');
const path = require('path'); const path = require('path');
const router = express.Router(); const router = express.Router();
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red'; const SERVER_DIR = process.env.SERVER_DIR || '/mc-server';
function isAuthenticated(req, res, next) { function isAuthenticated(req, res, next) {
if (req.session.user) { if (req.session.user) {

View File

@@ -3,7 +3,7 @@ const fs = require('fs-extra');
const path = require('path'); const path = require('path');
const router = express.Router(); const router = express.Router();
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red'; const SERVER_DIR = process.env.SERVER_DIR || '/mc-server';
function isAuthenticated(req, res, next) { function isAuthenticated(req, res, next) {
if (req.session.user) { if (req.session.user) {

View File

@@ -9,7 +9,7 @@ dotenv.config();
const app = express(); const app = express();
const PORT = process.env.PORT || 4001; const PORT = process.env.PORT || 4001;
const SERVER_DIR = process.env.SERVER_DIR || '/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red'; const SERVER_DIR = process.env.SERVER_DIR || '/mc-server';
// Déterminer le chemin du frontend (support Docker et local) // Déterminer le chemin du frontend (support Docker et local)
const frontendPath = (() => { const frontendPath = (() => {