title: Enabling CORS in ASP.NET Core API for React Native app
body: <p>I have an <code>ASP.NET Core 3.1</code> API backend which is already configured to allow <code>CORS</code> for my web app -- see below.</p>
  
  <p>I'm now building a mobile app in <code>React Native</code>. How do I add the specific origin for my <code>React Native</code> app so that my API accepts requests from my mobile app?</p>
  
  <p>I don't want to allow everyone and any app. I do want to keep it as secure as possible and specify my web and mobile apps.</p>
  
  <p>Here's what's currently in my <code>Startup.cs</code>:</p>
  
  <pre><code>services.AddCors(action =&gt;
         action.AddPolicy("AllowSpecificOrigin", builder =&gt;
            builder
            .AllowAnyMethod()
            .AllowAnyHeader()
            .WithOrigins("https://mywebapp.com", "http://localhost:50920", "https://myaccount.service.signalr.net", "http://localhost:3000")
            .AllowCredentials()));
  </code></pre>