<p>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:<br />
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:</p>
<pre><code>services.AddCors(x =&gt; 
    x.AddPolicy(&quot;my-cors&quot;, y=&gt; y.WithOrigins(&quot;https://subdomain.mydomain.com&quot;)
    .AllowAnyMethod().AllowAnyHeader().AllowCredentials()));

app.UseRouting();
app.UseCors(&quot;my-cors&quot;);
app.UseEndpoints(endpoints =&gt;
{
    endpoints.MapControllers();
    endpoints.MapHub&lt;MessageHub&gt;(&quot;/messageHub&quot;);
});


[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class MessageHub : Hub { ... }
</code></pre>
<p>In my ingress configuration I have this:</p>
<pre><code>kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
nginx.ingress.kubernetes.io/enable-cors: &quot;true&quot;
nginx.ingress.kubernetes.io/cors-allow-methods: &quot;PUT, GET, POST, OPTIONS&quot;
nginx.ingress.kubernetes.io/cors-expose-headers: &quot;*&quot;
nginx.ingress.kubernetes.io/cors-allow-origin: &quot;https://subdomain.mydomain.com&quot;
nginx.ingress.kubernetes.io/auth-tls-verify-client: &quot;on&quot;
nginx.ingress.kubernetes.io/auth-tls-secret: &quot;ingress-sps-tst/tls-secret&quot;
nginx.ingress.kubernetes.io/proxy-body-size: 50m
nginx.ingress.kubernetes.io/service-upstream: &quot;true&quot;
nginx.ingress.kubernetes.io/cors-allow-credentials: &quot;true&quot;
</code></pre>
<p>From the angular FE i do this:</p>
<pre><code>const hubConnection = new signalR.HubConnectionBuilder()
    .withUrl(this.signalREndpoint +'/messageHub', {
      accessTokenFactory: () =&gt; token,
    }).build();

hubConnection.start().then(....)
</code></pre>

lulluakok
<p>I'm facing the same issue when configuring SignalR for my project using SPA framework. But my error information is a little different from you <code>Request header field x-signalr-user-agent is not allowed by Access-Control-Allow-Headers in preflight response</code></p>
<p>After spending a lot of time for research in the internet and Ingress Nginx document. I can solve problems with CORS policy configuration.</p>
<p>In your annotations section of metadata using following config:</p>
<pre><code>metadata:
  name: ingress-svc
  annotations:
    kubernetes.io/ingress.class: nginx

    # CORS for api setup
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
    nginx.ingress.kubernetes.io/enable-cors: &quot;true&quot;
    nginx.ingress.kubernetes.io/cors-allow-methods: &quot;GET, POST, PUT, DELETE, PATCH, OPTIONS&quot;
    nginx.ingress.kubernetes.io/cors-allow-origin: &quot;http://localhost:3000&quot;
    nginx.ingress.kubernetes.io/cors-allow-headers: &quot;Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,X-SignalR-User-Agent&quot;
    nginx.ingress.kubernetes.io/cors-allow-credentials: &quot;true&quot;
</code></pre>
<p>As you can see <code>nginx.ingress.kubernetes.io/cors-allow-headers</code> in document they say the default value does not include what SignalR need <strong>X-SignalR-User-Agent</strong>. Read about it in <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#enable-cors" rel="nofollow noreferrer">here</a></p>
<p>Using this config now my project can run without any problem.</p>
<p><img src="https://i.stack.imgur.com/IxbsL.png" alt="Network result tab" /></p>
