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