Fix server URL in prod
This commit is contained in:
+17
-1
@@ -3,6 +3,7 @@ using backend.Services.Init;
|
||||
using Hangfire;
|
||||
using Hangfire.Dashboard;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Scalar.AspNetCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -24,7 +25,22 @@ builder.Services.SetupConfiguration(configuration);
|
||||
builder.Services.ConfigureServices(configuration);
|
||||
builder.Services.SetupDatabase(configuration);
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddOpenApi();
|
||||
builder.Services.AddOpenApi(options =>
|
||||
{
|
||||
//in production, override the server URL
|
||||
if (!isDevelopment)
|
||||
{
|
||||
options.AddDocumentTransformer((document, _, _) =>
|
||||
{
|
||||
document.Servers.Clear();
|
||||
document.Servers.Add(new OpenApiServer
|
||||
{
|
||||
Url = "https://fuelwizard.au"
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var allowedOrigins = Environment.GetEnvironmentVariable("ALLOWED_ORIGINS")?.Split(',') ??
|
||||
configuration.GetSection("AllowedOrigins").Get<string[]>();
|
||||
|
||||
Reference in New Issue
Block a user