CORS on Caddyserver version 1

To add the CORS authorization to the header using Caddy 1, simply add the following line inside your caddyfile:


This will allow all resources to be accessed from every domain.

You can also be more specific, i.e. allow specific resources to specific domains:

cors /foo

There are many more options you can use, here is a full example, as shown in the caddyserver docs:

cors / {
  methods           POST,PUT
  allow_credentials false
  max_age           3600
  allowed_headers   X-Custom-Header,X-Foobar
  exposed_headers   X-Something-Special,SomethingElse

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