/etc/caddy/Caddyfile
(cors) {
@{args.0} header Origin {args.0}
header @{args.0} Access-Control-Allow-Origin {args.0}
header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
header Access-Control-Allow-Headers "Content-Type, Authorization, Time-Zone"
header Access-Control-Max-Age "3600"
header Access-Control-Allow-Credentials true
}
domain.example.com {
...
import cors https://example.com
import cors https://www.example.com
import cors https://another.example.com
...
}
https://johnsiu.com/blog/caddyfile/#multiple