From 5ad4516a70dc4c537f1e3d381edead692964cbd3 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Sat, 17 Nov 2018 15:05:18 -0800 Subject: [PATCH] Protect against TypeError Only attempt to call req.headers.accept.include() if req.headers.accept exists. --- routes/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/user.js b/routes/user.js index de9e9e4..073fbf1 100644 --- a/routes/user.js +++ b/routes/user.js @@ -15,7 +15,7 @@ router.get('/:name', function (req, res) { if (result === undefined) { return res.status(404).json(`No record found for ${name}.`); } - else if (req.headers.accept.includes('application/activity+json') || req.headers.accept.includes('application/json') || req.headers.accept.includes('application/json+ld')) { + else if (req.headers.accept && (req.headers.accept.includes('application/activity+json') || req.headers.accept.includes('application/json') || req.headers.accept.includes('application/json+ld'))) { res.json(JSON.parse(result.actor)); } else {