Ah, it’s because header
sets "deferred": true
in the underlying JSON, so the header isn’t added until after the response starts being written (after templates does its thing).
I will change it so that it is not deferred when adding or setting, but is deferred for deleting headers… that should fix it up. But yeah, that Caddyfile is right, pending this change.