diff --git a/lib/middleware/error-handler.js b/lib/middleware/error-handler.js index 6894cb0..4c71fce 100644 --- a/lib/middleware/error-handler.js +++ b/lib/middleware/error-handler.js @@ -20,9 +20,9 @@ module.exports = function (options) { function formatError(error) { const output = error.output || {}; return { - status: output.statusCode ? output.statusCode.toString() : null, - title: error.name, - detail: error.message + status: output.statusCode ? output.statusCode.toString() : '500', + title: output.payload ? output.payload.error : error.name, + detail: output.payload ? output.payload.message : (error.message || error.toString()) }; } diff --git a/lib/middleware/response-json-api.js b/lib/middleware/response-json-api.js index fa3855c..219c666 100644 --- a/lib/middleware/response-json-api.js +++ b/lib/middleware/response-json-api.js @@ -109,7 +109,7 @@ module.exports = function (options) { defaultPort = true; } - if (defaultPort) { + if (!defaultPort) { baseUrl = `${baseUrl}:${port}`; } if (BASE_PREFIX) {