/// <summary> /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> public void Configure( IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, DatabaseSeeder databaseSeeder ) { if (env.IsDevelopment()) { // Seed database Task.Run(() => databaseSeeder.SeedRolesAsync()).Wait(); Task.Run(() => databaseSeeder.SeedUsersAsync()).Wait(); app.UseMiddleware(typeof(ErrorHandlingMiddleware)); } else { app.UseHsts(); } app.UseHttpsRedirection(); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); // Global CORS policy app.UseCors(x => x .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); app.UseAuthentication(); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve the Swagger UI (HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "An API v1"); }); app.UseMvc(); }