und das ist mein problem.
auf meinem entwicklungsserver bekomme ich den pfad auch so zusammengebaut:
/home/ubuntu/workspace/package/skillmatrixtool/js/view/../../../html/main.html
aber jetzt wo ich einen zweiten identischen server gestartet habe und es dort ausprobiere baut er mir den pfad so zusammen:
/home/ubuntu/workspace/package/skillmatrixtool/js/view../html/main.html
der code ist für beide server der gleiche:
config.json:
{
"routings": [
{
"route": "/",
"pathToHtmlFile":"../../../html",
"htmlFileName": "main.html",
"sessionSite": 0
},
{
"route": "/registrieren",
"pathToHtmlFile":"../../../html",
"htmlFileName": "registrieren.html",
"sessionSite": 0
},
{
"route": "/datenschutz",
"pathToHtmlFile":"../../../html",
"htmlFileName": "datenschutz.html",
"sessionSite": 0
},
{
"route": "/kontakt",
"pathToHtmlFile":"../../../html",
"htmlFileName": "kontakt.html",
"sessionSite": 0
},
{
"route": "/einstellungen",
"pathToHtmlFile":"../../../html",
"htmlFileName": "/einstellungen.html",
"sessionSite": 1
},
{
"route": "/skills",
"pathToHtmlFile":"../../../html",
"htmlFileName": "team.html",
"sessionSite": 1
},
{
"route": "/mitarbeiter",
"pathToHtmlFile":"../../../html",
"htmlFileName": "mitarbeiter.html",
"sessionSite": 1
},
{
"route": "/dashboard",
"pathToHtmlFile":"../../../pivottable/examples",
"htmlFileName": "/d3.html",
"sessionSite": 1
},
{
"route": "/details",
"pathToHtmlFile":"../../../html",
"htmlFileName": "mitarbeiterDetails.html",
"sessionSite": 1
},
{
"route": "/admin",
"pathToHtmlFile":"../../../html",
"htmlFileName": "admin.html",
"sessionSite": 1
}
],
"clientRessourcen": [
{
"clientPath": "/ressourcen",
"serverPath": "../../../ressourcen"
},
{
"clientPath": "/js",
"serverPath": "../../../js"
},
{
"clientPath": "/pivottable",
"serverPath": "../../../pivottable"
}
]
}
und im ordner view meine view.js:
/**
* View.
*/
function View(configJson, dbManager) {
var express = require('express');
var session = require('express-session');
var myParser = require("body-parser");
const Services = require('./services.js');
/**
* Verschickt den HTML-Client an den Browser.
*/
this.sendClient = function() {
"use strict";
var app = createApp();
Services(app, dbManager);
var port = process.env.port || 8080;
for(var i = 0; i < configJson.routings.length; i++) {
let file = configJson.routings[i];
if(file.sessionSite == 0) {
app.get(file.route, function(req, res) {
res.sendfile(file.htmlFileName, { root: __dirname + file.pathToHtmlFile });
});
} else {
app.get(file.route, function(req, res) {
if(req.session.email && (req.session.user || file.htmlFileName == "/d3.html" || file.htmlFileName == "/einstellungen.html")) {
if(!req.session.user && file.htmlFileName == "/d3.html") {
res.sendfile("/d3small.html", { root: __dirname + file.pathToHtmlFile });
} else if (!req.session.user && file.htmlFileName == "/einstellungen.html") {
res.sendfile("/einstellungenSmall.html", { root: __dirname + file.pathToHtmlFile });
} else {
res.sendfile(file.htmlFileName, { root: __dirname + file.pathToHtmlFile });
}
} else {
var rootFile = configJson.routings[0];
res.sendfile(rootFile.htmlFileName, { root: __dirname + rootFile.pathToHtmlFile });
}
});
}
}
app.listen(port);
}
/**
* Erstellt eine Web Application mittels Express.
*/
function createApp() {
var app = express();
app.use(myParser.urlencoded({extended : true}));
app.use(session({
secret: '2C44-4D44-WppQ38S',
resave: true,
saveUninitialized: true
}));
for(var i = 0; i < configJson.clientRessourcen.length; i++) {
var clientRessource = configJson.clientRessourcen[i];
app.use(clientRessource.clientPath, express.static(__dirname + clientRessource.serverPath));
}
return app;
}
}
module.exports = View;
:-( wieso geht das auf dem einen und auf dem anderen nicht..... wuuuusaaaaaa :-((((((