Hangfire Dashboard broken after deployment

i am using hangFire with .Net Core 3.1. Dashboard was working fine on local but when we deployed on Production Linux server container it got broken, I guess CSS was missing.

I am not able to resolve this problem. Please help.

Thanks

!

I finally found the solution by my self, issue was with url of css and js, after deploying it to containers our nginx was adding prefix url to navigate to job.

ex- url on local was - http://localhost:3200/Hangfire
url for css - http://localhost:3200/Hangfire/10700cs

after deployment job url -http://server.com/jobs/Hangfire

here “jobs” is the prefix url.

url for css - http://server.com/Hangfire/10700CS ->“this was the problem” hangfire was not adding the correct route prefix for css

correct url was - http://server.com/jobs/Hangfire/10700CS

to fix this from container you have to manage it to point to correct url (which i don’t know how to do it)

but from code we can do it as-

    app.Use((context, next) =>
    {
        // note : comment this to debug locally 
        context.Request.PathBase = Configuration["HangfireConnection:perfix"];
        return next();
    });
    app.UseHangfireDashboard("/Hangfire", new DashboardOptions
    {
        Authorization = new[] { new AuthorizationFilter() }
    })
    .UseHangfireServer();

first add prefix in config and read it from code or you can directly pass it as well :smile:
context.Request.PathBase = "jobs";

hope it helps

Thanks,

Raj

2 Likes

thanks @raj_yadav it works very well

1 Like

Thanks raj yadav, this works for me