Last active
February 10, 2026 01:32
-
-
Save ryanburnette/d13575c9ced201e73f8169d3a793c1a3 to your computer and use it in GitHub Desktop.
Caddy v2.1+ CORS whitelist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (cors) { | |
| @cors_preflight{args.0} { | |
| method OPTIONS | |
| header Origin {args.0} | |
| } | |
| handle @cors_preflight{args.0} { | |
| header { | |
| Access-Control-Allow-Origin "{args.0}" | |
| Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS" | |
| Access-Control-Allow-Headers * | |
| Access-Control-Max-Age "3600" | |
| defer | |
| } | |
| respond "" 204 | |
| } | |
| handle @cors{args.0} { | |
| header { | |
| Access-Control-Allow-Origin "{args.0}" | |
| Access-Control-Expose-Headers * | |
| defer | |
| } | |
| } | |
| } | |
| myawesomewebsite.com { | |
| root * /srv/public/ | |
| file_server | |
| import cors https://member.myawesomewebsite.com | |
| import cors https://customer.myawesomewebsite.com | |
| } |
Author
Author
@coolaj86 It could be a good time to review and update https://webinstall.dev/caddy if you are still including this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@DurandA Thanks, updated.