title: “gzip”

sitename: “Caddy中文文档”

http.cors

Caddy默认不支持此功能。如果需要,下载之前需要勾选上http.cors插件。

完整文档

例子

简单用法

  1. cors

允许所有来源访问所有资源

只允许指定的来源访问域名

  1. cors / http://mytrusteddomain.tld http://myotherdomain.com

只允许来自指定的几个域名的跨域请求。

完整配置

  1. cors / {
  2. origin http://allowedSite.com
  3. origin http://anotherSite.org https://anotherSite.org
  4. methods POST,PUT
  5. allow_credentials false
  6. max_age 3600
  7. allowed_headers X-Custom-Header,X-Foobar
  8. exposed_headers X-Something-Special,SomethingElse
  9. }

这个例子展示了所有可用的选项。