Make all the paths relative. This allows the application work behind a reverse proxy with any URL prepended.
parent
0b11b7c986
commit
a67981fde1
13
app.js
13
app.js
|
@ -12,6 +12,14 @@ var busboy = require('connect-busboy'); // for file upload
|
|||
|
||||
// include the routes
|
||||
var routes = require("./routes").routes;
|
||||
var js_routes = {};
|
||||
for (var key in routes) {
|
||||
var js_route = routes[key];
|
||||
if (/^\/./.test(js_route)) {
|
||||
js_route = js_route.replace(/^\//, '');
|
||||
}
|
||||
js_routes[key] = js_route;
|
||||
}
|
||||
|
||||
// set the view engine to ejs
|
||||
app.set('view engine', 'ejs');
|
||||
|
@ -25,7 +33,6 @@ app.use(busboy()); // to support file uploads
|
|||
|
||||
// include all folders
|
||||
app.use(express.static(__dirname + '/public'));
|
||||
app.use(express.static(__dirname + '/public/css'));
|
||||
app.use(express.static(__dirname + '/public/js'));
|
||||
app.use(express.static(__dirname + '/config'));
|
||||
app.set('views', __dirname + '/views');
|
||||
|
@ -43,7 +50,7 @@ app.get(routes.root, function(req, res) {
|
|||
// send all the required parameters
|
||||
crontab.crontabs( function(docs){
|
||||
res.render('index', {
|
||||
routes : JSON.stringify(routes),
|
||||
routes : JSON.stringify(js_routes),
|
||||
crontabs : JSON.stringify(docs),
|
||||
backups : crontab.get_backup_names(),
|
||||
env : crontab.get_env(),
|
||||
|
@ -106,7 +113,7 @@ app.get(routes.restore, function(req, res) {
|
|||
// get all the crontabs
|
||||
restore.crontabs(req.query.db, function(docs){
|
||||
res.render('restore', {
|
||||
routes : JSON.stringify(routes),
|
||||
routes : JSON.stringify(js_routes),
|
||||
crontabs : JSON.stringify(docs),
|
||||
backups : crontab.get_backup_names(),
|
||||
db: req.query.db
|
||||
|
|
|
@ -160,7 +160,7 @@ function doBackup(){
|
|||
function delete_backup(db_name){
|
||||
messageBox("<p> Do you want to delete this backup? </p>", "Confirm delete", null, null, function(){
|
||||
$.get(routes.delete_backup, {db: db_name}, function(){
|
||||
location = routes.root;
|
||||
location = '.';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ function delete_backup(db_name){
|
|||
function restore_backup(db_name){
|
||||
messageBox("<p> Do you want to restore this backup? </p>", "Confirm restore", null, null, function(){
|
||||
$.get(routes.restore_backup, {db: db_name}, function(){
|
||||
location = routes.root;
|
||||
location = '.';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<script src="bootstrap.min.js"></script>
|
||||
<script src="mailconfig.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/v/bs/dt-1.10.12/datatables.min.js"></script>
|
||||
<link rel="stylesheet" href="bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css"/>
|
||||
<script type="text/javascript">
|
||||
var crontabs = [];
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<script src="jquery.js"></script>
|
||||
<script src="script.js"></script>
|
||||
<script src="bootstrap.min.js"></script>
|
||||
<link rel="stylesheet" href="bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css" />
|
||||
<script type="text/javascript">
|
||||
var crontabs = [];
|
||||
var routes = [];
|
||||
|
|
Loading…
Reference in New Issue