Iterating over a comma deliminated environment variable

I think that’s more “smarts” than the Caddyfile was designed for. I don’t think we’ll implement something like that.

You’re probably better off writing a bash script which performs those expansions yourself. Emit it to a file like caddy-cors.txt, mount that at runtime, then do import /etc/caddy/caddy-cors.txt. The file would have this in it:

@origin-example1.com header Origin example1.com
header @origin-example1.com Access-Control-Allow-Origin "example1.com"
header @origin-example1.com Vary Origin

@origin-example2.com header Origin example2.com
header @origin-example2.com Access-Control-Allow-Origin "example2.com"
header @origin-example2.com Vary Origin
1 Like