To add the CORS authorization to the header using Caddy 2, simply add the following lines inside the site declaration:
sitename.com { file_server 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.
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.
Save 39% on CORS in Action with promotional code hossainco at manning.com/hossain