How do I set a header_down for a reverse proxy serving static files?

1. The problem I’m having:

I am serving a static folder and have a reverse proxy setup. I’m not able to figure out how to set a header_down for this static folder. Need to set a CORS policy

2. Error messages and/or full log output:

Error: adapting config using caddyfile: parsing caddyfile tokens for 'handle': unrecognized directive: header_down - are you sure your Caddyfile structure (nesting and braces) is correct?, at Caddyfile:34

3. Caddy version:

2.8.4

4. How I installed and ran Caddy:

a. System environment:

Ubuntu via apt

b. Command:

sudo /usr/bin/caddy run --watch

d. My complete Caddy config:

example.com {
        handle_path /myfolder/* {
                reverse_proxy localhost:3000
        #       header_down Access-Control-Allow-Origin *
                header_down {
                        Access-Control-Allow-Origin *
                }
        }       

        handle {
                reverse_proxy localhost:8002
        }
}

5. Links to relevant resources:

I’ve also tried the following:

(cors) {
        @destination header Access-Control-Allow-Origin "*"
}

example.com {
        import cors example.com
        handle_path /office/* {
                reverse_proxy localhost:3000
#               header_down Access-Control-Allow-Origin *
        #       header_down {
        #               Access-Control-Allow-Origin *
        #       }
        }

        handle {
                reverse_proxy localhost:8002
        }
}

But the response doesn’t include the header ;(

Moving the import cors example.com line to inside the handle_path directive similarly doesn’t work.

The header_down subdirective goes inside the reverse_proxy block. Refer to the syntax section here:

Oh, yeah, that does work. I tried that before but I guess I got the syntax of it wrong. This seems to work:

example.com { 
        handle_path /office/* {
                reverse_proxy localhost:3000 {
                        header_down Access-Control-Allow-Origin *
                }
        }

        handle {
                reverse_proxy localhost:8002
        }
}