Skip to content

Instantly share code, notes, and snippets.

@mufasa71
Forked from vanodevium/Caddyfile
Created January 25, 2026 14:28
Show Gist options
  • Select an option

  • Save mufasa71/fa26fd832c91a90e67542cbdcd842e3f to your computer and use it in GitHub Desktop.

Select an option

Save mufasa71/fa26fd832c91a90e67542cbdcd842e3f to your computer and use it in GitHub Desktop.
Caddy server: enable CORS for any domain
(cors) {
@cors_preflight method OPTIONS
header {
Access-Control-Allow-Origin "{header.origin}"
Vary Origin
Access-Control-Expose-Headers "Authorization"
Access-Control-Allow-Credentials "true"
}
handle @cors_preflight {
header {
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE"
Access-Control-Max-Age "3600"
}
respond "" 204
}
}
:80 {
import cors {header.origin}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment