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:
@@ -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));
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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: ''
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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 = (() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user