mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Fixed /api/batch request recreation failure
This commit is contained in:
parent
a19b92a5cb
commit
92a7355ce3
1 changed files with 14 additions and 1 deletions
|
|
@ -18,7 +18,20 @@ export async function POST(request: Request) {
|
||||||
|
|
||||||
let index = 0;
|
let index = 0;
|
||||||
for (const data of body) {
|
for (const data of body) {
|
||||||
const newRequest = new Request(request, { body: JSON.stringify(data) });
|
// Recreate a fresh Request since `new Request(request)` will have the following error:
|
||||||
|
// > Cannot read private member #state from an object whose class did not declare it
|
||||||
|
|
||||||
|
// Copy headers we received, ensure JSON content type, and avoid conflicting content-length
|
||||||
|
const headers = new Headers(request.headers);
|
||||||
|
headers.set('content-type', 'application/json');
|
||||||
|
headers.delete('content-length');
|
||||||
|
|
||||||
|
const newRequest = new Request(request.url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers,
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
});
|
||||||
|
|
||||||
const response = await send.POST(newRequest);
|
const response = await send.POST(newRequest);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue