Do CloudFlare Apps work with Workers?

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?

Workers are still not available for Cloudflare Apps.

Hmm are you sure about?

This page made me think it was possible to enable apps:

Like this:

  optimization: {
    apps: true,
    cacheEverything: true,
    cacheTtl: 86400,
    mirage: true,
    polish: 'off',
    minify: {
      javascript: true,
      css: true,
      html: true,

But it doesn’t appear to be working, although the other options are.

It used to be possible, but isn’t any more since they don’t accept new applications.

@harris maybe someone can update the page?

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:

fetch(request, { cf: { apps: true } })