Commit ebd36637 authored by Vadym Gidulian's avatar Vadym Gidulian

Added proper Content-Type header for 4xx error

parent 230272f6
......@@ -20,7 +20,9 @@ module.exports = {
await requestValidator(req, res, _next);
if (nextWatcher.wasCalled) return nextWatcher.doNext();
} catch (e) { // Probably bad request
return res.status(400).send(e.message);
return res.status(400)
.set('Content-Type', 'text/plain')
.send(e.message);
}
}
......@@ -30,7 +32,9 @@ module.exports = {
if (nextWatcher.wasCalled) return nextWatcher.doNext();
} catch (e) { // Operation error
const code = e.code || (e.response && e.response.code);
if (/^4\d\d/.test(code)) return res.status(code).send(e.message);
if (/^4\d\d/.test(code)) return res.status(code)
.set('Content-Type', 'text/plain')
.send(e.message);
return next(e);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment