Access-Control-Allow-Origin Multiple Origin Domains?

前端 未结 30 2050
隐瞒了意图╮
隐瞒了意图╮ 2020-11-21 07:08

Is there a way to allow multiple cross-domains using the Access-Control-Allow-Origin header?

I\'m aware of the *, but it is too open. I rea

30条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-21 07:27

    For multiple domains, in your .htaccess:

    
        SetEnvIf Origin "http(s)?://(www\.)?(domain1.example|domain2.example)$" AccessControlAllowOrigin=$0$1
        Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
        Header set Access-Control-Allow-Credentials true
    
    

提交回复
热议问题