From c468e2f34e654c4900fea27835334e19a95284a5 Mon Sep 17 00:00:00 2001 From: Varghese Thomas Date: Fri, 11 Aug 2017 20:46:59 +0530 Subject: [PATCH 1/3] Sending not found page for invalid url id --- server/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/server.js b/server/server.js index 3164ff3d..4e6361b3 100644 --- a/server/server.js +++ b/server/server.js @@ -148,7 +148,7 @@ app.get('/exists/:id', async (req, res) => { app.get('/download/:id', async (req, res) => { const id = req.params.id; if (!validateID(id)) { - res.sendStatus(404); + res.status(404).render('notfound'); return; } From a9c1dd01807c93ed42ba820bc16131fef7619ad2 Mon Sep 17 00:00:00 2001 From: Varghese Thomas Date: Fri, 11 Aug 2017 20:52:18 +0530 Subject: [PATCH 2/3] Replacing all send status 404 with notfound page --- server/server.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/server.js b/server/server.js index 4e6361b3..2579b4ee 100644 --- a/server/server.js +++ b/server/server.js @@ -133,7 +133,7 @@ app.get('/jsconfig.js', (req, res) => { app.get('/exists/:id', async (req, res) => { const id = req.params.id; if (!validateID(id)) { - res.sendStatus(404); + res.status(404).render('notfound'); return; } @@ -141,7 +141,7 @@ app.get('/exists/:id', async (req, res) => { await storage.exists(id); res.sendStatus(200); } catch (e) { - res.sendStatus(404); + res.status(404).render('notfound'); } }); @@ -172,7 +172,7 @@ app.get('/download/:id', async (req, res) => { app.get('/assets/download/:id', async (req, res) => { const id = req.params.id; if (!validateID(id)) { - res.sendStatus(404); + res.status(404).render('notfound'); return; } @@ -197,7 +197,7 @@ app.get('/assets/download/:id', async (req, res) => { file_stream.pipe(res); } catch (e) { - res.sendStatus(404); + res.status(404).render('notfound'); } }); @@ -205,14 +205,14 @@ app.post('/delete/:id', async (req, res) => { const id = req.params.id; if (!validateID(id)) { - res.sendStatus(404); + res.status(404).render('notfound'); return; } const delete_token = req.body.delete_token; if (!delete_token) { - res.sendStatus(404); + res.status(404).render('notfound'); return; } @@ -222,7 +222,7 @@ app.post('/delete/:id', async (req, res) => { res.sendStatus(200); } } catch (e) { - res.sendStatus(404); + res.status(404).render('notfound'); } }); @@ -242,7 +242,7 @@ app.post('/upload', (req, res, next) => { !meta.hasOwnProperty('filename') || !validateIV(meta.id) ) { - res.sendStatus(404); + res.status(404).render('notfound'); return; } From 70813556ad418e1981e88699b74a2fd3617ef839 Mon Sep 17 00:00:00 2001 From: Varghese Thomas Date: Sat, 12 Aug 2017 00:29:25 +0530 Subject: [PATCH 3/3] Reverting unwanted notfound page response --- server/server.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/server.js b/server/server.js index 2579b4ee..4e6361b3 100644 --- a/server/server.js +++ b/server/server.js @@ -133,7 +133,7 @@ app.get('/jsconfig.js', (req, res) => { app.get('/exists/:id', async (req, res) => { const id = req.params.id; if (!validateID(id)) { - res.status(404).render('notfound'); + res.sendStatus(404); return; } @@ -141,7 +141,7 @@ app.get('/exists/:id', async (req, res) => { await storage.exists(id); res.sendStatus(200); } catch (e) { - res.status(404).render('notfound'); + res.sendStatus(404); } }); @@ -172,7 +172,7 @@ app.get('/download/:id', async (req, res) => { app.get('/assets/download/:id', async (req, res) => { const id = req.params.id; if (!validateID(id)) { - res.status(404).render('notfound'); + res.sendStatus(404); return; } @@ -197,7 +197,7 @@ app.get('/assets/download/:id', async (req, res) => { file_stream.pipe(res); } catch (e) { - res.status(404).render('notfound'); + res.sendStatus(404); } }); @@ -205,14 +205,14 @@ app.post('/delete/:id', async (req, res) => { const id = req.params.id; if (!validateID(id)) { - res.status(404).render('notfound'); + res.sendStatus(404); return; } const delete_token = req.body.delete_token; if (!delete_token) { - res.status(404).render('notfound'); + res.sendStatus(404); return; } @@ -222,7 +222,7 @@ app.post('/delete/:id', async (req, res) => { res.sendStatus(200); } } catch (e) { - res.status(404).render('notfound'); + res.sendStatus(404); } }); @@ -242,7 +242,7 @@ app.post('/upload', (req, res, next) => { !meta.hasOwnProperty('filename') || !validateIV(meta.id) ) { - res.status(404).render('notfound'); + res.sendStatus(404); return; }