From f5010af4f1c90ca518ba6983ba009c9c47743240 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Wed, 30 Dec 2015 00:33:36 -0500 Subject: Added 404 and 403 status on routes --- app.js | 8 ++++++++ lib/response.js | 2 +- public/js/index.js | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 64b5b5f8..cf82f443 100644 --- a/app.js +++ b/app.js @@ -141,6 +141,14 @@ app.set('views', __dirname + '/public'); app.engine('html', ejs.renderFile); //get index app.get("/", response.showIndex); +//get 403 forbidden +app.get("/403", function(req, res) { + response.errorForbidden(res); +}); +//get 404 not found +app.get("/404", function(req, res) { + response.errorNotFound(res); +}); //get status app.get("/status", function (req, res, next) { realtime.getStatus(function (data) { diff --git a/lib/response.js b/lib/response.js index 375fc3f4..6a180f2b 100644 --- a/lib/response.js +++ b/lib/response.js @@ -36,7 +36,7 @@ var opts = { //public var response = { errorForbidden: function (res) { - res.status(403).send("Forbidden, oh no."); + responseError(res, "403", "Forbidden", "oh no."); }, errorNotFound: function (res) { responseError(res, "404", "Not Found", "oops."); diff --git a/public/js/index.js b/public/js/index.js index f37244bb..e9be3de0 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1133,7 +1133,11 @@ socket.emit = function () { }; socket.on('info', function (data) { console.error(data); - location.href = "./404.html"; + location.href = "./404"; +}); +socket.on('error', function (data) { + console.error(data); + location.href = "./403"; }); socket.on('disconnect', function (data) { showStatus(statusType.offline); -- cgit v1.2.3