1
0

Added support for more json type headers

This commit is contained in:
2021-06-13 12:34:41 +02:00
parent 038219310b
commit d63bdcbaab
2 changed files with 2 additions and 2 deletions

View File

@@ -349,7 +349,7 @@ class Router {
}) })
} }
const headers = Object.assign({ 'Content-Type': 'application/json' }, response.headers) const headers = Object.assign({ 'Content-Type': 'application/json' }, response.headers)
if (headers['Content-Type'] === 'application/json' && typeof response.body === 'object') if (headers['Content-Type'].includes('json') && typeof response.body === 'object')
response.body = JSON.stringify(response.body) response.body = JSON.stringify(response.body)
return new Response(response.body, { return new Response(response.body, {
status: response.status || (response.body ? 200 : 500), status: response.status || (response.body ? 200 : 500),

View File

@@ -1,6 +1,6 @@
{ {
"name": "@tsndr/cloudflare-worker-router", "name": "@tsndr/cloudflare-worker-router",
"version": "1.1.1", "version": "1.1.2",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": {}, "scripts": {},