diff --git a/public/javascripts/spacedeck_routes.js b/public/javascripts/spacedeck_routes.js index 8e4fd4abef67f58b063562a52aa270eb2814f931..6796177bf49ce8de13e260ab2d278bddb95b6dff 100644 --- a/public/javascripts/spacedeck_routes.js +++ b/public/javascripts/spacedeck_routes.js @@ -11,7 +11,7 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/spaces/:id", + path: "/spacedeck/spaces/:id", handler: function(params, on_success) { this.load_space(params.id, on_success); }.bind(this) @@ -20,7 +20,7 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/s/:hash", + path: "/spacedeck/s/:hash", handler: function(params, on_success) { var parts = params.hash.split("-"); if (path.length > 0) { @@ -35,10 +35,10 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/confirm/:token", + path: "/spacedeck/confirm/:token", handler: function(params) { if (!this.logged_in) { - this.redirect_to("/login"); + this.redirect_to("/spacedeck/login"); } else { this.confirm_account(params.token); } @@ -48,13 +48,13 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/password-confirm/:token", + path: "/spacedeck/password-confirm/:token", handler: function(params) { console.log(params.token); if (this.logged_in) { - this.redirect_to("/spaces"); + this.redirect_to("/spacedeck/spaces"); } else { this.reset_token = params.token; this.active_view = "password-confirm"; @@ -66,7 +66,7 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/password-reset", + path: "/spacedeck/password-reset", handler: function(params, test) { if (this.logged_in) { } else { @@ -78,20 +78,20 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/accept/:membership_id", + path: "/spacedeck/accept/:membership_id", handler: function(params, test) { if (this.logged_in) { var invitation_token = get_query_param("code"); accept_invitation(params.membership_id, invitation_token , function(m) { window._spacedeck_location_change = true; - location.href = "/spaces/"+m.space._id; + location.href = "/spacedeck/spaces/"+m.space._id; }.bind(this), function(xhr) { smoke.alert("Error ("+xhr.status+")", function() { - this.redirect_to("/spaces"); + this.redirect_to("/spacedeck/spaces"); }.bind(this)); }.bind(this)); } else { - this.redirect_to("/login"); + this.redirect_to("/spacedeck/login"); } }.bind(this) } @@ -99,7 +99,7 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/signup", + path: "/spacedeck/signup", handler: function(params) { var invitation_token = get_query_param("code"); @@ -108,7 +108,7 @@ var SpacedeckRoutes = { } if (this.logged_in) { - this.redirect_to("/spaces"); + this.redirect_to("/spacedeck/spaces"); } else { this.active_view = "signup"; } @@ -119,7 +119,7 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/login", + path: "/spacedeck/login", handler: function(params) { if (this.logged_in) { if(this.invitation_token) { @@ -128,7 +128,7 @@ var SpacedeckRoutes = { location.href = "spaces/"+m.space_id; }.bind(this), function(xhr) { console.error(xhr); }); } else { - this.redirect_to("/spaces"); + this.redirect_to("/spacedeck/spaces"); } } else { this.active_view = "login"; @@ -143,14 +143,14 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/logout", + path: "/spacedeck/logout", handler: function(params) { if (this.logged_in) { this.logout(function(m) { - this.redirect_to("/login"); + this.redirect_to("/spacedeck/login"); }.bind(this), function(xhr) { console.error(xhr); }); } else { - this.redirect_to("/login"); + this.redirect_to("/spacedeck/login"); } }.bind(this) } @@ -158,17 +158,17 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/spaces", + path: "/spacedeck/spaces", handler: function(params) { if (!this.logged_in) { window._spacedeck_location_change = true; - location.href = "/login"; + location.href = "/spacedeck/login"; } else { if (this.logged_in && this.user.home_folder_id) { this.load_space(this.user.home_folder_id); } else { - location.href = "/"; + location.href = "/spacedeck/"; } } @@ -178,11 +178,11 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/account", + path: "/spacedeck/account", handler: function(params) { if (!this.logged_in) { window._spacedeck_location_change = true; - location.href = "/"; + location.href = "/spacedeck/"; } else { this.active_view = "account"; } @@ -193,11 +193,11 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/team", + path: "/spacedeck/team", handler: function(params) { if (!this.logged_in) { window._spacedeck_location_change = true; - location.href = "/"; + location.href = "/spacedeck/"; } else { this.active_view = "team"; this.load_team(); @@ -208,13 +208,13 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/folders/:id", + path: "/spacedeck/folders/:id", handler: function(params) { this.load_space(params.id, null, function(xhr) { // on_error console.log("couldn't load folder: "+xhr.status); - this.redirect_to("/spaces", function(){}); + this.redirect_to("/spacedeck/spaces", function(){}); }.bind(this)); }.bind(this) } @@ -223,27 +223,27 @@ var SpacedeckRoutes = { this.router.add([ { - path: "/", + path: "/spacedeck/", handler: function(params) { - location.href = "/"; + location.href = "/spacedeck/"; }.bind(this) } ]); this.router.add([ { - path: "/terms", + path: "/spacedeck/terms", handler: function(params) { - location.href = "/terms"; + location.href = "/spacedeck/terms"; }.bind(this) } ]); this.router.add([ { - path: "/privacy", + path: "/spacedeck/privacy", handler: function(params) { - location.href = "/privacy"; + location.href = "/spacedeck/privacy"; }.bind(this) } ]); @@ -253,7 +253,7 @@ var SpacedeckRoutes = { if (foundRoute) { foundRoute[0].handler(foundRoute[0].params, on_success); } else { - location.href = "/not_found"; + location.href = "/spacedeck/not_found"; } }, @@ -300,10 +300,10 @@ var SpacedeckRoutes = { }, link_to_parent_folder: function(space_id) { - return "/folders/"+space_id; + return "/spacedeck/folders/"+space_id; }, link_to_space: function(space) { - return "/"+space.space_type+"s/"+space._id; + return "/spacedeck/"+space.space_type+"s/"+space._id; } } diff --git a/spacedeck.js b/spacedeck.js index 6ac9dcbf4322bacba925999ba25ad19235666c34..39ae665bb8626be4f7dfe2d0d3531c5688da502f 100644 --- a/spacedeck.js +++ b/spacedeck.js @@ -69,11 +69,14 @@ app.use(cookieParser()); app.disable('x-powered-by'); //app.use(helmet.noSniff()) + +const endpoint = config.get('endpoint'); + //app.use(require("./middlewares/error_helpers")); //app.use(require("./middlewares/cors")); app.use(require("./middlewares/session")); app.use(require("./middlewares/i18n")); -app.use("/api", require("./middlewares/api_helpers")); +app.use(endpoint+"/api", require("./middlewares/api_helpers")); app.use('/api/spaces/:id', require("./middlewares/space_helpers")); app.use('/api/spaces/:id/artifacts/:artifact_id', require("./middlewares/artifact_helpers"));