title: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource?
body: <p>i publish my .net core application on IIS using <code>file system</code> , when i open the application in browser it wont connect to database and throw me below error (in console of firefox) , but if i run from VS 2019 it works fine without any error . Any help is really appreciated.</p>
  <p><code>Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://localhost:44374/api/userLogin/?username=test&amp;password=test. (Reason: CORS request did not succeed)</code></p>
  <p>This is my <code>appsetting</code> :</p>
  <pre><code>  &quot;Logging&quot;: {
        &quot;LogLevel&quot;: {
        &quot;Default&quot;: &quot;Information&quot;,
        &quot;Microsoft&quot;: &quot;Warning&quot;,
        &quot;Microsoft.Hosting.Lifetime&quot;: &quot;Information&quot;
        }
      },
    &quot;AllowedHosts&quot;: &quot;*&quot;,
    &quot;ConnectionStrings&quot;: {
      &quot;patientDB&quot;: &quot;Data Source=DESKTOP-FE7Q19U\\SQLEXPRESS;Initial Catalog=MDSS;Integrated Security=True&quot;
    }
  }
  </code></pre>
  <p>This is my <code>launchsetting</code>:</p>
  <pre><code>{
    &quot;iisSettings&quot;: {
      &quot;windowsAuthentication&quot;: false,
      &quot;anonymousAuthentication&quot;: true,
      &quot;iisExpress&quot;: {
        &quot;applicationUrl&quot;: &quot;http://localhost:51911&quot;,
        &quot;sslPort&quot;: 44374
      }
    },
    &quot;profiles&quot;: {
      &quot;IIS Express&quot;: {
        &quot;commandName&quot;: &quot;IISExpress&quot;,
        &quot;launchBrowser&quot;: true,
        &quot;environmentVariables&quot;: {
          &quot;ASPNETCORE_ENVIRONMENT&quot;: &quot;Development&quot;
        }
      },
      &quot;ReactC_MDSS&quot;: {
        &quot;commandName&quot;: &quot;Project&quot;,
        &quot;launchBrowser&quot;: true,
        &quot;applicationUrl&quot;: &quot;https://localhost:5001;http://localhost:5000&quot;,
        &quot;environmentVariables&quot;: {
          &quot;ASPNETCORE_ENVIRONMENT&quot;: &quot;Development&quot;
        }
      }
    }
  }
  </code></pre>
  <p>This is my <code>startup</code>:</p>
  <pre><code>public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
  
              services.AddControllersWithViews();
              services.AddDbContext&lt;patientDbContext&gt;(o =&gt; o.UseSqlServer(Configuration.GetConnectionString(&quot;patientDB&quot;)));
             
              // In production, the React files will be served from this directory
              services.AddSpaStaticFiles(configuration =&gt;
              {
                  configuration.RootPath = &quot;ClientApp/build&quot;;
              });
  
  
     
  
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseExceptionHandler(&quot;/Error&quot;);
                  // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                  app.UseHsts();
              }
  
              app.UseHttpsRedirection();
              app.UseStaticFiles();
              app.UseSpaStaticFiles();
  
              
  
              app.UseRouting();
  
              app.UseEndpoints(endpoints =&gt;
              {
                  endpoints.MapControllerRoute(
                      name: &quot;default&quot;,
                      pattern: &quot;{controller}/{action=Index}/{id?}&quot;);
              });
  
              app.UseSpa(spa =&gt;
              {
                  spa.Options.SourcePath = &quot;ClientApp&quot;;
  
                  if (env.IsDevelopment())
                  {
                      spa.UseReactDevelopmentServer(npmScript: &quot;start&quot;);
                  }
              });
          }
      }
  }
  </code></pre>
  <p>I try to add cors but somehow it not worked.</p>