嗨,如何解决CaddyServer中的访问控制允许来源?

时间:2019-01-25 13:31:38

标签: cors caddy

我在服务器上托管了两个站点

https:// mydomain.com {
      root /var/www/html
     gzip
}
https:// api.mydomain.com {
     proxy /  http://NODE_IP:3001
 }

然后,“ mydomain .com”将与“ api.mydomain .com”对话以获取资源,但出现“访问控制允许来源”错误,我尝试了两种方法来解决此问题,但它没有用。 一种是使用“标头/ api Access-Control-Allow-Origin *”

https://api.mydomain.com {
    header /api Access-Control-Allow-Origin *
    proxy /  http://NODE_IP:3001
 }'
two :

https://api.mydomain.com {
       cors
       proxy /  http://NODE_IP:3001
}
or something like this:
cors / { 
   origin http://allowedSite.com 
   origin http://anotherSite.org https://anotherSite.org 
   methods POST,PUT 
   allow_credentials false max_age 3600 
   allowed_headers X-Custom-Header,X-Foobar 
   exposed_headers X-Something-Special,SomethingElse 
}

Can someone help me to solve this? Thank you very much! :neutral_face:



0 个答案:

没有答案