Security implications of adding all domains to CORS (Access-Control-Allow-Origin: *)

后端 未结 6 910
深忆病人
深忆病人 2020-12-07 22:51

It is said that instead of adding all domains to CORS, one should only add a set of domains. Yet it is sometimes not trivial to add a set of domains. E.g. if I want to publi

6条回答
  •  悲&欢浪女
    2020-12-07 23:27

    Best Practice is to first check the domain of the incoming request and then generate the response header. Depending on whether this domain is allowed to send requests, you add it (just this one) to the Access-Control-Allow-Origin response header.

    Afaik, it is not even possible to add more than one domain to this header. So it's either * or one specific domain and I would always prefer not to add *

提交回复
热议问题