From e9b66c2e4190a4bdd0d8a7c4330a0400387c2229 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 5 Aug 2017 12:23:06 +0430 Subject: [PATCH] feat: response json to curl clients on error --- lib/core/renderer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/core/renderer.js b/lib/core/renderer.js index 053e22c9e0..20fc30fe44 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -294,7 +294,8 @@ export default class Renderer extends Tapable { } // Check if request accepts JSON - const isJson = (req.headers.accept || '').toLowerCase().includes('application/json') + const hasReqHeader = (header, includes) => req.headers[header] && req.headers[header].toLowerCase().includes(includes) + const isJson = hasReqHeader('accept', 'application/json') || hasReqHeader('user-agent', 'curl/') // Use basic errors when debug mode is disabled if (!this.options.render.debug) {