Prepopulate request, don't parse body for DELETE method
This commit is contained in:
@@ -152,7 +152,6 @@ Key | Type | Description
|
||||
`params` | `object` | Object containing all parameters defined in the url string
|
||||
`query` | `object` | Object containing all query parameters
|
||||
|
||||
|
||||
### `res`-Object
|
||||
|
||||
Key | Type | Description
|
||||
|
||||
6
index.js
6
index.js
@@ -323,7 +323,9 @@ class Router {
|
||||
method: request.method,
|
||||
headers: request.headers,
|
||||
url: request.url,
|
||||
params: []
|
||||
params: [],
|
||||
query: {},
|
||||
body: ''
|
||||
}
|
||||
if (req.method === 'OPTIONS' && Object.keys(this.corsConfig).length) {
|
||||
return new Response(null, {
|
||||
@@ -336,7 +338,7 @@ class Router {
|
||||
status: this.corsConfig.optionsSuccessStatus
|
||||
})
|
||||
}
|
||||
if (['POST', 'PUT', 'PATCH', 'DELETE'].includes(req.method)) {
|
||||
if (['POST', 'PUT', 'PATCH'].includes(req.method)) {
|
||||
if (req.headers.has('Content-Type') && req.headers.get('Content-Type').includes('json')) {
|
||||
try {
|
||||
req.body = await request.json()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tsndr/cloudflare-worker-router",
|
||||
"version": "1.2.2",
|
||||
"version": "1.2.3",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {},
|
||||
|
||||
Reference in New Issue
Block a user