Liunx下部署hangfire无法打开面板

发布时间 2023-09-14 17:30:25作者: 黄明辉

若没有hangfir面板的过滤器IDashboardAuthorizationFilter,在打开/hangfire路径时请求会返回401未授权。
需要添加类继承IDashboardAuthorizationFilter过滤器类

    public class CustomerHangfireDashboardFilter : IDashboardAuthorizationFilter
    {
        public bool Authorize([NotNull] DashboardContext context)
        {

            return true;
        }
    }
并且在StartUp注册使用
app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
//hangfire 身份验证过滤器
Authorization = new[] { new CustomerHangfireDashboardFilter() },
});