I've been reading up on how to properly secure APIs that support dynamic cors headers. Not sure if I fully understand the problem with wildcarding any subdomain.
if (preg_match('|\.?my-site.com$|', $_SERVER['SERVER_NAME'])) {
   header('Access-Control-Allow-Origin: *');
   header('Vary: Origin,Accept-Encoding');
}
(My API supports both HTTP and HTTPS, and is fronted by Varnish)
questions
- Is there a drawback to using Access-Control-Allow-Origin: *vs the actual origin making the request?
- What security benefits do I gain by adding Vary: Origin, Accept-Encoding? I read about the need for them when reading about cache poisoning, but can't say I understand the implications here.
 
     
     
    