Access-Control-Allow-Origin Multiple Origin Domains?

前端 未结 30 2063
隐瞒了意图╮
隐瞒了意图╮ 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:34

    HTTP_ORIGIN is not used by all browsers. How secure is HTTP_ORIGIN? For me it comes up empty in FF.
    I have the sites that I allow access to my site send over a site ID, I then check my DB for the record with that id and get the SITE_URL column value (www.yoursite.com).

    header('Access-Control-Allow-Origin: http://'.$row['SITE_URL']);
    

    Even if the send over a valid site ID the request needs to be from the domain listed in my DB associated with that site ID.

提交回复
热议问题