18
18
using Microsoft . AspNetCore . SignalR ;
19
19
using Microsoft . Extensions . DependencyInjection ;
20
20
using Microsoft . Extensions . Hosting ;
21
+ using Microsoft . Extensions . Logging ;
21
22
using Microsoft . Extensions . Primitives ;
22
23
using Microsoft . IdentityModel . Tokens ;
23
24
using Microsoft . Net . Http . Headers ;
@@ -104,7 +105,7 @@ public void ConfigureServices(IServiceCollection services)
104
105
} ) ;
105
106
}
106
107
107
- public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
108
+ public void Configure ( IApplicationBuilder app , IWebHostEnvironment env , ILogger < Startup > logger )
108
109
{
109
110
if ( env . IsDevelopment ( ) )
110
111
{
@@ -120,6 +121,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
120
121
var originHeader = context . Request . Headers [ HeaderNames . Origin ] ;
121
122
if ( ! StringValues . IsNullOrEmpty ( originHeader ) )
122
123
{
124
+ logger . LogInformation ( "Setting CORS headers." ) ;
123
125
context . Response . Headers [ HeaderNames . AccessControlAllowOrigin ] = originHeader ;
124
126
context . Response . Headers [ HeaderNames . AccessControlAllowCredentials ] = "true" ;
125
127
@@ -138,6 +140,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
138
140
139
141
if ( HttpMethods . IsOptions ( context . Request . Method ) )
140
142
{
143
+ logger . LogInformation ( "Setting '204' CORS response." ) ;
141
144
context . Response . StatusCode = StatusCodes . Status204NoContent ;
142
145
return Task . CompletedTask ;
143
146
}
0 commit comments