'CORS issue using SignalR through Kubernetes

I'm trying to connect my angular FE with my signalR hub in my backend (.NET core) that is hosted inside kubernetes, when I try I get this error message:
has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Does anyone know how to solve this? this is my configuration:

services.AddCors(x => 
    x.AddPolicy("my-cors", y=> y.WithOrigins("https://subdomain.mydomain.com")
    .AllowAnyMethod().AllowAnyHeader().AllowCredentials()));

app.UseRouting();
app.UseCors("my-cors");
app.UseEndpoints(endpoints =>
{
    endpoints.MapControllers();
    endpoints.MapHub<MessageHub>("/messageHub");
});


[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class MessageHub : Hub { ... }

In my ingress configuration I have this:

kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-methods: "PUT, GET, POST, OPTIONS"
nginx.ingress.kubernetes.io/cors-expose-headers: "*"
nginx.ingress.kubernetes.io/cors-allow-origin: "https://subdomain.mydomain.com"
nginx.ingress.kubernetes.io/auth-tls-verify-client: "on"
nginx.ingress.kubernetes.io/auth-tls-secret: "ingress-sps-tst/tls-secret"
nginx.ingress.kubernetes.io/proxy-body-size: 50m
nginx.ingress.kubernetes.io/service-upstream: "true"
nginx.ingress.kubernetes.io/cors-allow-credentials: "true"

From the angular FE i do this:

const hubConnection = new signalR.HubConnectionBuilder()
    .withUrl(this.signalREndpoint +'/messageHub', {
      accessTokenFactory: () => token,
    }).build();

hubConnection.start().then(....)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source