Skip to content

Commit

Permalink
Minor changes in the middleware pipeline:
Browse files Browse the repository at this point in the history
 added HSTS; CORS used in PROD only; minor changes in order and added comments
  • Loading branch information
AKlaus committed May 4, 2021
1 parent fa47b2d commit c9b2d31
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions back-end/WebApi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

using Raven.Yabt.Domain.Infrastructure;
using Raven.Yabt.WebApi.Configuration;
Expand Down Expand Up @@ -51,18 +52,27 @@ public void ConfigureServices(IServiceCollection services)
/// </summary>
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AppSettings appSettings)
{
app.UseHttpsRedirection();

app.AddAppExceptionHandler(env);
if (env.IsDevelopment())
// CORS is used for development only
app.UseCors();
else
{ // Enforce use of HTTPS
app.UseHsts();
app.UseHttpsRedirection();
}

app.UseRouting();
app.UseCors();
app.AddAppExceptionHandler(env);

app.UseAuthentication();

app.AddAppSwaggerUi();

app.UseEndpoints(endpoints => endpoints.MapControllers());
// Matches request to an endpoint
app.UseRouting();
// Executes the matched endpoint
app.UseEndpoints(endpoints =>
endpoints.MapControllers() // Maps attributes on the controllers, like, [Route], [HttpGet], etc.
);

app.AddAppSpaStaticFiles(appSettings.UserApiKey);
}
Expand Down

0 comments on commit c9b2d31

Please sign in to comment.