ansible-caddy/roles/install/templates/etc/caddy/cors.j2
GregoryDosh 8d2bc9806f
All checks were successful
Version Bump Galaxy.yml / Version Bump Galaxy.yml (push) Successful in 4s
chore: restructure templates to include destination dir
2025-11-18 17:22:03 -06:00

32 lines
873 B
Django/Jinja

# SPDX-License-Identifier: AGPL-3.0-or-later
# SPDX-FileCopyrightText: Ihor Kalnytskyi
# Referenced from https://kalnytskyi.com/posts/setup-cors-caddy-2/
# and https://caddy.community/t/how-can-i-allow-multiple-domain-origins-in-cors/22129
@cors_preflight{args[0]} {
method OPTIONS
header Origin {args[0]}
}
@cors{args[0]} header Origin {args[0]}
handle @cors_preflight{args[0]} {
header {
Access-Control-Allow-Origin "{args[0]}"
Access-Control-Allow-Credentials true
Access-Control-Allow-Headers "{{CADDY_CADDYFILE_CORS_ALLOW_HEADERS}}"
Access-Control-Allow-Methods "{{CADDY_CADDYFILE_CORS_ALLOW_METHODS}}"
Access-Control-Max-Age "3600"
Vary Origin
defer
}
respond "" 204
}
handle @cors{args[0]} {
header {
Access-Control-Allow-Origin "{args[0]}"
Access-Control-Allow-Credentials true
Access-Control-Expose-Headers *
Vary Origin
defer
}
}