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
I wanted to develop a simple client side web app which works with REST APIs provided by dotnet-monitor tool. My reasoning behind developing this client application was that, system admins could get rich UI experience for APIs provided by dotnet-monitor without need of other tools. The client side app would be a static site which can be configured to use one or more REST endpoint of dotnet-monitor tool and to be navigated via UI without manually providing URLs in the browser. Static app like this can be even embedded inside the tool itself to provide user experience for admins (and I agree that this scenario will not require CORS management in app itself).
Issue
When I started development, I found that, direct queries cannot be sent by browser application to the APIs provided by the tool because API does not support CORS rules.
Solution
I have worked on proof-of-concept for this which will allow user to configure CORS rules.
CORS rules for dotnet-monitor can be provided in two ways,
Command line parameter: dotnet monitor collect --corsAllowedOrigins {origin}. This only allows user to enter allowed origins for running instance of dotnet-monitor. User can enter one or more origins using this parameter, values provided here will be merged with origins provided in appsettings.json file.
Using static configuration using appsettings.json section. This allows user to configure all CorsPolicy properties defined in Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy class. appsettings.json section can be configured as below,
I really would appreciate if you could take this request to consideration and add it to the tool. I can make pull requests to the repository to make this change available if required.
The text was updated successfully, but these errors were encountered:
@noahfalk That's really really nice to hear! 😊 I'm adding few more features to the app. You will see new updates in the repo soon. Here's small glance of it,
If you or anyone had chance to look at the code and see any issue with how it written, please don't hesitate to ping back at me. I'm gladly take any criticism you have. 😊
Reasonning
I wanted to develop a simple client side web app which works with REST APIs provided by
dotnet-monitor
tool. My reasoning behind developing this client application was that, system admins could get rich UI experience for APIs provided bydotnet-monitor
without need of other tools. The client side app would be a static site which can be configured to use one or more REST endpoint ofdotnet-monitor
tool and to be navigated via UI without manually providing URLs in the browser. Static app like this can be even embedded inside the tool itself to provide user experience for admins (and I agree that this scenario will not require CORS management in app itself).Issue
When I started development, I found that, direct queries cannot be sent by browser application to the APIs provided by the tool because API does not support CORS rules.
Solution
I have worked on proof-of-concept for this which will allow user to configure CORS rules.
CORS rules for
dotnet-monitor
can be provided in two ways,Command line parameter:
dotnet monitor collect --corsAllowedOrigins {origin}
. This only allows user to enter allowed origins for running instance ofdotnet-monitor
. User can enter one or more origins using this parameter, values provided here will be merged with origins provided inappsettings.json
file.Using static configuration using
appsettings.json
section. This allows user to configure allCorsPolicy
properties defined inMicrosoft.AspNetCore.Cors.Infrastructure.CorsPolicy
class.appsettings.json
section can be configured as below,Implementation
Proof-of-concept implementation changes can be found in this commit in my fork.
As a highlight, changes are
Program.cs
Above rule is added as an argument for
CommandHandler.Create
DiagnosticsMonitorCommandHandler.cs
Above logic has added inside
.ConfigureServices((WebHostBuilderContext context, IServiceCollection services) =>
block to create the CORS policy.Startup.cs
Finally added
UseCors
toStartup
class so runtime can use the configured CORS policy.Repository with the updated code can be found here: https://github.com/SachiraChin/diagnostics/
Conclusion
I really would appreciate if you could take this request to consideration and add it to the tool. I can make pull requests to the repository to make this change available if required.
The text was updated successfully, but these errors were encountered: