Access-Control-Allow-Origin Multiple Origin Domains?

前端 未结 30 2486
隐瞒了意图╮
隐瞒了意图╮ 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条回答
  •  轮回少年
    2020-11-21 07:25

    This worked for me:

    SetEnvIf Origin "^http(s)?://(.+\.)?(domain\.example|domain2\.example)$" origin_is=$0 
    Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is
    

    When put in .htaccess, it will work for sure.

提交回复
热议问题