Access-Control-Allow-Origin Multiple Origin Domains?

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

    Here's how to echo the Origin header back if it matches your domain with Nginx, this is useful if you want to serve a font multiple sub-domains:

    location /fonts {
        # this will echo back the origin header
        if ($http_origin ~ "example.org$") {
            add_header "Access-Control-Allow-Origin" $http_origin;
        }
    }
    

提交回复
热议问题