I have a worker setup on a subdomain that is proxied through CloudFlare.
I’ve tried enabling the app Add HTML to add code to the header, but it’s not actually adding it. In the preview it works perfectly, but when viewing the site, it’s not there.
Does Apps like that not work when the HTML is generated by Workers?
That’s correct, if the worker is directly generating the HTML, then Apps (which don’t themselves include a worker) don’t apply to the response. Apps can apply to responses to subrequests, though, if the subrequest includes the cf.apps property. To put it another way, you need an origin to be able to apply Apps. In retrospect, this was a mistake that we’d like to fix one day, but doing so without breaking anyone is tricky.
Note that the documentation is correct – to enable apps on subrequests, you’d do something like this: