Skip to content

Commit a6d68eb

Browse files
committed
fix: attempt to fix not found page in deployed app in azure app service
1 parent 2779b4c commit a6d68eb

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

AdminHubApi/Program.cs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
builder.Services.AddSwaggerGen(option =>
2222
{
2323
option.SwaggerDoc("v1", new OpenApiInfo { Title = "Admin Hub Api", Version = "v1" });
24+
2425
option.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
2526
{
2627
In = ParameterLocation.Header,
@@ -30,18 +31,19 @@
3031
BearerFormat = "JWT",
3132
Scheme = "Bearer"
3233
});
34+
3335
option.AddSecurityRequirement(new OpenApiSecurityRequirement
3436
{
3537
{
3638
new OpenApiSecurityScheme
3739
{
3840
Reference = new OpenApiReference
3941
{
40-
Type=ReferenceType.SecurityScheme,
41-
Id="Bearer"
42+
Type = ReferenceType.SecurityScheme,
43+
Id = "Bearer"
4244
}
4345
},
44-
new string[]{}
46+
new string[] { }
4547
}
4648
});
4749
});
@@ -96,11 +98,27 @@
9698

9799
app.UseSwagger();
98100

99-
// Configure the HTTP request pipeline.
100-
if (app.Environment.IsDevelopment())
101+
app.UseSwaggerUI(options =>
101102
{
102-
app.UseSwaggerUI();
103-
}
103+
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Web API V1");
104+
105+
if (app.Environment.IsDevelopment())
106+
{
107+
options.RoutePrefix = "swagger";
108+
}
109+
else
110+
{
111+
options.RoutePrefix = string.Empty;
112+
}
113+
});
114+
115+
app.UseSwagger();
116+
117+
// // Configure the HTTP request pipeline.
118+
// if (app.Environment.IsDevelopment())
119+
// {
120+
// app.UseSwaggerUI();
121+
// }
104122

105123
app.UseHttpsRedirection();
106124

0 commit comments

Comments
 (0)