Access-Control-Allow-Origin Multiple Origin Domains?

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

    Below answer is specific to C#, but the concept should be applicable to all the different platforms.

    To allow Cross Origin Requests from a web api, You need to allow Option requests to your Application and Add below annotation at controller level.

    [EnableCors(UrlString,Header, Method)] Now the origins can be passed only a s string. SO if you want to pass more than one URL in the request pass it as a comma seperated value.

    UrlString = "https://a.hello.com,https://b.hello.com"

提交回复
热议问题