mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-15 05:35:01 +00:00
Only enable SignalR detailed errors in development
Changed EnableDetailedErrors to be conditional based on: - Debugger attached (DebuggerHelper.IsAttached) - context.HostingEnvironment.IsDevelopment() Updated ConfigureServices to accept WebHostBuilderContext to properly access the hosting environment instead of directly reading environment variables. This prevents detailed error messages from being exposed in production builds, which is important for security.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
using ElectronNET.Runtime.Helpers;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for <see cref="IWebHostBuilder"/> to enable Electron.NET
|
||||
@@ -90,7 +91,7 @@
|
||||
builder = builder.UseUrls($"http://{host}:{webPort}");
|
||||
}
|
||||
|
||||
builder = builder.ConfigureServices(services =>
|
||||
builder = builder.ConfigureServices((context, services) =>
|
||||
{
|
||||
services.AddTransient<IStartupFilter, ServerReadyStartupFilter>();
|
||||
services.AddSingleton<AspNetLifetimeAdapter>();
|
||||
@@ -109,8 +110,10 @@
|
||||
case StartupMethod.UnpackedDotnetFirstSignalR:
|
||||
services.AddSignalR(options =>
|
||||
{
|
||||
// Enable detailed errors for debugging
|
||||
options.EnableDetailedErrors = true;
|
||||
// Enable detailed errors only in development for security
|
||||
options.EnableDetailedErrors =
|
||||
DebuggerHelper.IsAttached ||
|
||||
context.HostingEnvironment.IsDevelopment();
|
||||
});
|
||||
services.AddSingleton<IElectronNetRuntimeController, RuntimeControllerAspNetDotnetFirstSignalR>();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user