Skip to content

Commit 99b8f9c

Browse files
committed
Gate back-office dev static proxy on IsRunningInAzure instead of IsDevelopment
1 parent a075a7f commit 99b8f9c

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

application/account/Api/BackOfficeDevStaticProxy.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
using System.Net;
22
using System.Net.Security;
33
using Microsoft.AspNetCore.Http.Extensions;
4+
using SharedKernel.Configuration;
45
using Yarp.ReverseProxy.Forwarder;
56

67
namespace Account.Api;
78

8-
// Dev-only proxy that forwards back-office static-asset and HMR traffic from the back-office Kestrel
9-
// listener (BACK_OFFICE_KESTREL_PORT) to the rsbuild dev server (BACK_OFFICE_STATIC_PORT). Production
10-
// builds bake the bundle into BackOfficeWebApp/dist and serve it via UseStaticFiles, so this proxy
11-
// is registered only in development. The proxy must run before authentication so anonymous browsers
12-
// can fetch /static/*, /rsbuild-hmr, and HMR /{filename}.hot-update.{ext} during the SPA bootstrap.
9+
// Non-Azure proxy that forwards back-office static-asset and HMR traffic from the back-office Kestrel
10+
// listener (BACK_OFFICE_KESTREL_PORT) to the rsbuild dev server (BACK_OFFICE_STATIC_PORT). Azure
11+
// deployments bake the bundle into BackOfficeWebApp/dist and serve it via UseStaticFiles, so this
12+
// proxy is registered only outside Azure. The proxy must run before authentication so anonymous
13+
// browsers can fetch /static/*, /rsbuild-hmr, and HMR /{filename}.hot-update.{ext} during the SPA
14+
// bootstrap.
1315
public static class BackOfficeDevStaticProxy
1416
{
1517
public static IServiceCollection AddBackOfficeDevStaticProxy(this IServiceCollection services)
@@ -20,7 +22,7 @@ public static IServiceCollection AddBackOfficeDevStaticProxy(this IServiceCollec
2022

2123
public static IApplicationBuilder UseBackOfficeDevStaticProxy(this WebApplication app, string backOfficeHostname)
2224
{
23-
if (!app.Environment.IsDevelopment()) return app;
25+
if (SharedInfrastructureConfiguration.IsRunningInAzure) return app;
2426

2527
var rawPort = Environment.GetEnvironmentVariable("BACK_OFFICE_STATIC_PORT");
2628
if (!int.TryParse(rawPort, out var staticPort) || staticPort <= 0) return app;

0 commit comments

Comments
 (0)