CORS on Caddyserver version 2

To add the CORS authorization to the header using Caddy 2, simply add the following lines inside the site declaration: {
  encode zstd gzip

  header {
    Access-Control-Allow-Headers *
    Access-Control-Allow-Methods *
    Access-Control-Allow-Origin *
  @options {
    method OPTIONS
  respond @options 204
Instructions for Caddy Version 1 (older version) can be found here.

Who’s behind this

Monsur Hossain and Michael Hausenblas


The content on this site stays fresh thanks to help from users like you! If you have suggestions or would like to contribute, fork us on GitHub.

Buy the book

Save 39% on CORS in Action with promotional code hossainco at