handle multiple domains with Access-Control-Allow-Origin header in Apache

后端 未结 8 912
独厮守ぢ
独厮守ぢ 2020-12-08 10:17

I want to configure apache for cross-domain access header. I have tried multiple combination as suggested on number of threads on the forum. But its not working for me.

8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 10:21

    This works for me in Classic ASP:

    If Request.ServerVariables("HTTP_ORIGIN") = "http://domain1.com" Then
      Response.AddHeader "Access-Control-Allow-Origin","http://domain1.com"
    ElseIf Request.ServerVariables("HTTP_ORIGIN") = "http://domain2.com" Then
      Response.AddHeader "Access-Control-Allow-Origin","http://domain2.com"
    'and so on
    End If
    

提交回复
热议问题