mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 19:36:12 +01:00
set correct content type for error messages
This commit is contained in:
@@ -120,6 +120,10 @@ function apiResultHandler(req, res, result) {
|
||||
|
||||
function send(res, statusCode, response) {
|
||||
if (typeof response === 'string') {
|
||||
if (statusCode >= 400) {
|
||||
res.setHeader("Content-Type", "text/plain");
|
||||
}
|
||||
|
||||
res.status(statusCode).send(response);
|
||||
|
||||
return response.length;
|
||||
@@ -167,7 +171,9 @@ function route(method, path, middleware, routeHandler, resultHandler, transactio
|
||||
.catch(e => {
|
||||
log.error(`${method} ${path} threw exception: ` + e.stack);
|
||||
|
||||
res.status(500).send(e.message);
|
||||
res.setHeader("Content-Type", "text/plain")
|
||||
.status(500)
|
||||
.send(e.message);
|
||||
});
|
||||
}
|
||||
else {
|
||||
@@ -180,7 +186,9 @@ function route(method, path, middleware, routeHandler, resultHandler, transactio
|
||||
catch (e) {
|
||||
log.error(`${method} ${path} threw exception: ` + e.stack);
|
||||
|
||||
res.status(500).send(e.message);
|
||||
res.setHeader("Content-Type", "text/plain")
|
||||
.status(500)
|
||||
.send(e.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user