Fix server URL in prod

This commit is contained in:
kurt-mcrae
2025-05-28 21:57:08 +10:00
parent f43677aa78
commit 3e74e3298c
+17 -1
View File
@@ -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[]>();