With my cloudflare worker I fail with
With my cloudflare worker I fail with the error
[mf:err] Cause: RequestContentLengthMismatchError: Request body length does not match content-length header
from the following API response:
I think this is because there are 2 content-length headers, and the first one is no the correct length. Looking at resources online it seems like when multiple are provided then it should take the last one. This is when streaming the response https://developers.cloudflare.com/workers/learning/using-streams/12 Replies
or potentially if there is a way to ignore this error and just use the last content-length that would be great
Hey @danthegoodman , could you please share a bit of your code to understand this better?
Yeah sec, you'd need to make a tinybird account. I've also been in contact with thier support
@Vero 🐙 they said they couldnt' recreate it which is weird, let me try to they just got back to me as well
AH ok it only happens locally
when using
wrangler dev
where it's hosted on CF it works fine, but when running in local mode it breaks
{"successful_rows":2,"quarantined_rows":0}
is there response body, trying to get the header
here is what is passed through when it works (CF hosted test)
so seems just to be an issue with miniflareI suspect it's due to reuse of the original request headers.
Try
request.headers.delete('content-length')
before const res = await fetch (...
doing
ah
Try that instead
Could also make an object from the headers.entries() but I don't know that syntax from the top of my head
yep that worked
tysm @kiannh !
Awesome
you are awesome Kian
goated