File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,12 +7,12 @@ namespace ECommerce.AdminUI.Filters;
77public class AuthenticationFilter : IPageFilter
88{
99 private readonly ILogger < AuthenticationFilter > _logger ;
10-
10+
1111 public AuthenticationFilter ( ILogger < AuthenticationFilter > logger )
1212 {
1313 _logger = logger ;
1414 }
15-
15+
1616 public void OnPageHandlerSelected ( PageHandlerSelectedContext context )
1717 {
1818 // No action needed
@@ -22,19 +22,18 @@ public void OnPageHandlerExecuting(PageHandlerExecutingContext context)
2222 {
2323 // Skip authentication check for Login page to avoid infinite redirect loop
2424 // Also skip for HealthCheck endpoint used by Kubernetes probes
25- if ( context . HandlerInstance is Pages . LoginModel ||
26- context . HandlerInstance is Pages . HealthCheckModel )
25+ if ( context . HandlerInstance is Pages . LoginModel or Pages . HealthCheckModel )
2726 {
2827 return ;
2928 }
30-
29+
3130 var httpContext = context . HttpContext ;
3231 var token = httpContext . Session . GetString ( "AuthToken" ) ;
33-
32+
3433 if ( string . IsNullOrEmpty ( token ) )
3534 {
3635 _logger . LogInformation ( "Unauthenticated access attempt to {Path}" , httpContext . Request . Path ) ;
37-
36+
3837 // Redirect to login page
3938 context . Result = new RedirectToPageResult ( "/Login" ) ;
4039 }
Original file line number Diff line number Diff line change 9494builder . Services . AddScoped < ECommerce . AdminUI . Services . OrderService > ( ) ;
9595
9696var app = builder . Build ( ) ;
97+ var logger = app . Logger ;
98+
99+ // Log ASPNETCORE_PATHBASE value at startup
100+ string ? pathBase = app . Configuration [ "ASPNETCORE_PATHBASE" ] ?? Environment . GetEnvironmentVariable ( "ASPNETCORE_PATHBASE" ) ;
101+ logger . LogInformation ( "ASPNETCORE_PATHBASE is set to: \' {PathBase}\' " , pathBase ) ;
102+
103+ // Apply the path base if it's set
104+ if ( ! string . IsNullOrEmpty ( pathBase ) )
105+ {
106+ app . UsePathBase ( pathBase ) ;
107+ app . Use ( ( context , next ) =>
108+ {
109+ context . Request . PathBase = pathBase ;
110+ return next ( ) ;
111+ } ) ;
112+ logger . LogInformation ( "Path base applied: {PathBase}" , pathBase ) ;
113+ }
97114
98115// Configure the HTTP request pipeline.
99116if ( ! app . Environment . IsDevelopment ( ) )
You can’t perform that action at this time.
0 commit comments