11using System . Net ;
22using System . Net . Security ;
33using Microsoft . AspNetCore . Http . Extensions ;
4+ using SharedKernel . Configuration ;
45using Yarp . ReverseProxy . Forwarder ;
56
67namespace 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.
1315public 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