Best method: Access-Control-Allow-Origin Multiple Origin Domains

后端 未结 2 2028
迷失自我
迷失自我 2021-02-03 21:27

This question has been asked on here before and given an array of good answers, mainly: Access-Control-Allow-Origin Multiple Origin Domains?

However there seems to be a

2条回答
  •  灰色年华
    2021-02-03 21:50

    If you need to allow a origin which contains a specific word "example" you may use the following configuration in your apache vhost.

    SetEnvIf Origin "^((?:https?:\/\/)?(?:[^@\n]+@)?(?:www.)?.example?.*)" REFERER=$0 
    Header always set Access-Control-Allow-Origin %{REFERER}e env=REFERER
    

    This will satisfy some of the following Origin conditions:

    http://abc.bcd.example.com
    https://www.example.in 
    http://abcdexample.com 
    many more
    

    You may tweak the above regex as per your requirement.

提交回复
热议问题