I set CORS in my .net core application like this:
app.UseCors(builder => builder
.WithOrigins("https://*.example.com")
.SetIsOriginAllowedToAllowWildcardSubdomains()
.SetIsOriginAllowed(origin => _configuration.GetSection("Cors:AllowedOrigins").Get<IList<string>>().Contains(origin))
.AllowAnyHeader()
.AllowAnyMethod());
The server response header is:
access-control-allow-origin: https://*.example.com
So I don't understand why I get this error because it looks like it has support for any sub-domain.
This is the full error:
login:1 Access to fetch at 'https://staging.example.com/' from origin 'https://app.example.com' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'https://*.example.com' that is not equal to the supplied origin. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Any idea why I get this error even though I try to access from a sub-domain of example.com
?
According to the docs this should work.