Skip to content

Commit

Permalink
#113: Don't use HTTPS redirection if environment doesn't support it.
Browse files Browse the repository at this point in the history
  • Loading branch information
kwokkan committed Dec 31, 2019
1 parent 032b053 commit 0ff88c4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion apps/CardHero.NetCoreApp.TypeScript/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ namespace CardHero.NetCoreApp.TypeScript
{
public class Startup
{
private static class CardHeroEnvironmentVariables
{
public const string DisableHttps = "CH_DISABLE_HTTPS";
}

private readonly IConfiguration _configuration;
private readonly IWebHostEnvironment _environment;

Expand Down Expand Up @@ -158,11 +163,17 @@ public void ConfigureServices(IServiceCollection services)
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseForwardedHeaders();

app.UseJsonException();

// 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();

if (string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(CardHeroEnvironmentVariables.DisableHttps)))
{
app.UseHttpsRedirection();
}

app.UseResponseCompression();

Expand Down

0 comments on commit 0ff88c4

Please sign in to comment.