Hi,
I’m very interested into making the same thing. But I can’t achieve adding the subpath.
Here is my config:
app.get('/mineos' + '/', function(req, res){
res.redirect('/admin/index.html');
});
app.get('/mineos' + '/admin/index.html', ensureAuthenticated, function(req, res){
res.sendFile('/html/index.html', response_options);
});
app.get('/mineos' + '/login', function(req, res){
res.sendFile('/html/login.html');
});
app.post('/mineos' + '/auth', passport.authenticate('local-signin', {
successRedirect: ('/admin/index.html'),
failureRedirect: ('/admin/login.html')
})
);
app.all('/mineos' + '/api/:server_name/:command', ensureAuthenticated, function(req, res) {
var target_server = req.params.server_name;
var user = req.user.username;
var instance = be.servers[target_server];
var args = req.body;
args['command'] = req.params.command;
if (instance)
instance.direct_dispatch(user, args);
else
console.error('Ignoring request by "', user, '"; no server found named [', target_server, ']');
res.end();
});
app.post('/mineos' + '/admin/command', ensureAuthenticated, function(req, res) {
var target_server = req.body.server_name;
var instance = be.servers[target_server];
var user = req.user.username;
if (instance)
instance.direct_dispatch(user, req.body);
else
console.error('Ignoring request by "', user, '"; no server found named [', target_server, ']');
res.end();
});
app.get('/mineos' + '/logout', function(req, res){
req.logout();
res.redirect('/admin/login.html');
});
app.use('/mineos' + '/socket.io', express.static(__dirname + '/node_modules/socket.io'));
app.use('/mineos' + '/angular', express.static(__dirname + '/node_modules/angular'));
app.use('/mineos' + '/angular-translate', express.static(__dirname + '/node_modules/angular-translate/dist'));
app.use('/mineos' + '/moment', express.static(__dirname + '/node_modules/moment'));
app.use('/mineos' + '/angular-moment', express.static(__dirname + '/node_modules/angular-moment'));
app.use('/mineos' + '/angular-moment-duration-format', express.static(__dirname + '/node_modules/moment-duration-format/lib'));
app.use('/mineos' + '/angular-sanitize', express.static(__dirname + '/node_modules/angular-sanitize'));
app.use('/mineos' + '/admin', express.static(__dirname + '/html'));
This doesn’t work. I get Cannot GET /admin/index.html
Could you help me to set that up ? You said that we should edit app.use, app.get, app.post but not res.sendFile. But what about res.redirect and app.all ?
Thanks in advance for any answer, have a great day