Skip to content

Commit

Permalink
Protect swagger behind dev env. (#6823)
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist committed Apr 29, 2024
1 parent 1fc4c19 commit f00417e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions orleans/Blazor/BlazorWasm/BlazorWasm.Server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models;
using Sample.Silo.Api;
using Orleans.Providers;

bool isDevelopment = false;

await Host.CreateDefaultBuilder(args)
.UseOrleans((ctx, builder) =>
{
isDevelopment = ctx.HostingEnvironment.IsDevelopment();
builder.UseLocalhostClustering();
builder.AddMemoryGrainStorageAsDefault();
builder.AddMemoryStreams<DefaultMemoryMessageBodySerializer>("MemoryStreams");
Expand Down Expand Up @@ -40,11 +44,15 @@ await Host.CreateDefaultBuilder(args)
.Configure(app =>
{
app.UseCors("ApiService");
app.UseSwagger();
app.UseSwaggerUI(options =>
if (isDevelopment)
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", nameof(Sample));
});
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", nameof(Sample));
});
}
app.UseRouting();
app.UseEndpoints(endpoints =>
Expand All @@ -61,4 +69,4 @@ await Host.CreateDefaultBuilder(args)
options.SuppressStatusMessages = true;
});
})
.RunConsoleAsync();
.RunConsoleAsync();

0 comments on commit f00417e

Please sign in to comment.