Why doesn't AddCors or AddJwtBearer have support for getting a registered DI/IoC item? #57750
-
Hi folks, So we have for example: The allowed origins are defined in configuration files/environment variables. Likewise with setting up authentication's AddJwtBearer .. we have this: again, some settings via configuration. I couldn't find any way to grab this from the existing DI/IoC if we have previously registered it. My guess is that the above code is still being handled/called during registration of all our services. So could this be added to the code? Would this mean that cors and jwtsettings would be setup upon first instansiation / request of the instance/data? It's like I wish to load all configuration data before configuring any services .. but this problem is that i load configuration settings during service configuration (into so confused :( |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Those are just the initial setting values, you can still configure the values after the calls to |
Beta Was this translation helpful? Give feedback.
Those are just the initial setting values, you can still configure the values after the calls to
AddCors
/AddJwtBearer
but before the service provider is built. Just registerIConfigureOptions<CorsOptions>
orIConfigureOptions<JwtBearerOptions>
and inject your configuration dependencies into those. You can then useConfigure
(orPostConfigure
withIPostConfigureOptions<>
) to complete the configuration using your dynamic values