Content-Length header is missing from most requests

I can see Content-Length when Im developing locally, but when deployed with Netlify the Content-Length header is missing. For example:

$ curl -I https://manifestsio.netlify.app/_next/static/chunks/webpack-8cac0b4b405cede1.js
HTTP/2 200
accept-ranges: bytes
age: 38
cache-control: public,max-age=604800,stale-while-revalidate=86400
cache-status: "Netlify Edge"; hit
content-type: application/javascript; charset=UTF-8
date: Tue, 19 Nov 2024 21:44:15 GMT
etag: "3df6f6ca087fa61eea5256ab91e6dc77-ssl-df"
server: Netlify
strict-transport-security: max-age=31536000; includeSubDomains; preload
vary: Accept-Encoding
x-nf-request-id: 01JD36472ADEV8FG5CJ9RV1RX7

This is true for most assets served by Netlify. A few static assets like images seem to have it, but none of the js assets have Content-Legnth headers. Am I missing something?

You seem to have a middleware running on all paths. Try excluding the above path from it and then you should see the content-length header.

Thanks for the reply hrishikesh. Is this something I would have configured on the netlify side or in code? I do set the cache-control header via netlify.toml for all paths, would that effect this?

It’s your middleware. You should configure the matcher to exclude it from running on all paths.