Skip to content

Commit f5010af

Browse files
committed
Added 404 and 403 status on routes
1 parent 5467e6d commit f5010af

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

app.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ app.set('views', __dirname + '/public');
141141
app.engine('html', ejs.renderFile);
142142
//get index
143143
app.get("/", response.showIndex);
144+
//get 403 forbidden
145+
app.get("/403", function(req, res) {
146+
response.errorForbidden(res);
147+
});
148+
//get 404 not found
149+
app.get("/404", function(req, res) {
150+
response.errorNotFound(res);
151+
});
144152
//get status
145153
app.get("/status", function (req, res, next) {
146154
realtime.getStatus(function (data) {

lib/response.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var opts = {
3636
//public
3737
var response = {
3838
errorForbidden: function (res) {
39-
res.status(403).send("Forbidden, oh no.");
39+
responseError(res, "403", "Forbidden", "oh no.");
4040
},
4141
errorNotFound: function (res) {
4242
responseError(res, "404", "Not Found", "oops.");

public/js/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,11 @@ socket.emit = function () {
11331133
};
11341134
socket.on('info', function (data) {
11351135
console.error(data);
1136-
location.href = "./404.html";
1136+
location.href = "./404";
1137+
});
1138+
socket.on('error', function (data) {
1139+
console.error(data);
1140+
location.href = "./403";
11371141
});
11381142
socket.on('disconnect', function (data) {
11391143
showStatus(statusType.offline);

0 commit comments

Comments
 (0)