Skip to content

Instantly share code, notes, and snippets.

@dunderrrrrr
Last active July 12, 2023 07:57
Show Gist options
  • Save dunderrrrrr/962953ea21eae12b724798759904c55f to your computer and use it in GitHub Desktop.
Save dunderrrrrr/962953ea21eae12b724798759904c55f to your computer and use it in GitHub Desktop.
Multiple CORS urls in Caddy

/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
  ...
}

@dunderrrrrr
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment