CloudFlare resets mime type for site css

I am working with CloudFlare on fixing a problem where their product pages somewhat arbitrarily resets the mime type of the site css file. On my custom domain they provided a work around using a JS worker that resets the mime type for css in the http response header.

The works for production, which is based on the master branch (or any designated branch), that gets published and accessible via the custom domain.

For “development” (any branch that is not production), CloudFlare generates a new random dev url (subdomain) for each deployment. At this point, it is not easy to use a Worker to perform the workaround (this is also something they are changing where you will be able to use workers with Pages. (Workers otherwise work with content you are serving on CloudFlare through their other services.).

I am wondering if there is anything in Hugo that could tell the web server what header to use for a resource type (namely, css in this case). I note that the doc section on [[headers]] says it applies only to the hugo server (which of course is a memory based server totally under hugo’s control).

Nope, there isn’t. Hugo just creates static websites. You need to tell the server what file-extensions mean what content type. Generally that is quite easy. But I read quite some issues with Cloudflare recently. Maybe they have some form of “content type by file extension” header in their product?

Yes, those setting mimics the header config on Netlify. I would assume that Cloudflare have a similar config for headers?

Not sure it can be accessed directly. The worker at Cloudflare does it dynamically, replacing the extension of any requested css file with an appropriate mime type at the cost of 1 ms per request. Hardly enough to matter. Would be better to do it once with a permanent change to the http header record.

Better yet not to set it wrongly to begin with. Monday they’ll be back on the job and I can see if it is possible to set the headers.

Seems clear that Hugo can’t do it on a server it can’t control.

  • Lewis