You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
docs/topics/cors.rst indicates that you define Allowed Origins like this:
var cors = new DefaultCorsPolicyService(_loggerFactory.CreateLogger())
{
AllowedOrigins = { "https://foo", "https://bar" }
};
services.AddSingleton(cors);
However, this was not working for me. What I did eventually get working is:
services.AddSingleton((container) => {
var logger = container.GetRequiredService<ILogger>();
return new DefaultCorsPolicyService(logger) {
AllowedOrigins = { "https://foo", "https://bar" }
};
});
I believe the reason that the former approach did not work is that an instance of _loggerFactory is no longer available in Startup.cs->ConfigureServices(). I believe this is due to a change Microsoft made in the approach to configuring logging in .NET Core 3.1.
The text was updated successfully, but these errors were encountered:
I am facing the same issue. the original code no longer works.
But the code suggested by @abarker11101 also does not work. it keeps saying that the ILogger provided by Microsoft is not compatible with the ILogger need by DefaultCorsPolicyService.
This is not a bug per se, more of a documentation issue. My apologies if I should have categorized it differently.
I previously submitted this change as a pull request (https://github.com/IdentityServer/IdentityServer4/pull/4404/files). Again my apologies, I don't think that was the best way to communicate what I believe to be a documentation issue.
docs/topics/cors.rst indicates that you define Allowed Origins like this:
var cors = new DefaultCorsPolicyService(_loggerFactory.CreateLogger())
{
AllowedOrigins = { "https://foo", "https://bar" }
};
services.AddSingleton(cors);
However, this was not working for me. What I did eventually get working is:
services.AddSingleton((container) => {
var logger = container.GetRequiredService<ILogger>();
return new DefaultCorsPolicyService(logger) {
AllowedOrigins = { "https://foo", "https://bar" }
};
});
I believe the reason that the former approach did not work is that an instance of _loggerFactory is no longer available in Startup.cs->ConfigureServices(). I believe this is due to a change Microsoft made in the approach to configuring logging in .NET Core 3.1.
The text was updated successfully, but these errors were encountered: