Include URL subpath when using Hangfire Dashboard

We have implemented a custom IDashboardAuthorizationFilter to authorize user by roles (received from a SAML Token) to access the hangfire dashboard. In our environement everything works fine, but when deployed in the customer environment (Test and Integration) because the js and css files can’t be loaded (404 not found) and the links within the dashboard do not point to the correct URL.

The reason lies in the routing/network configuration:


All calls including the subpath services/m-api are being routed to the backend, the others to the frontend.
Hangfire is being exposed from the backend.

Hangfire uses the root URL (https://intranet.ch/hangfire) whereas it should be using the URL forwarded to the backend (https://intranet.ch/services/m-api/hangfire).

How can we offer a functioning Hangfire Dashboard in the described customer szenario?

@ph.waeber I’m dealing with a similar issue with my application. Were you able to find a solution that worked for you?

I was able to resolve the issue I had by swapping out the Hangfire.AspNetCore nuget for the main Hangfire nuget. Not sure what exactly fixed it, but switching over got my dashboard working. I know that some people had issues with trailing slashes in the url, but that wasn’t an issue for me. Happy coding!

If you are using .netcore, PrefixPath works fine. (Make sure the first ‘/’ must be included)

app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
    PrefixPath = app.Environment.IsDevelopment() ? "" : "/services/m-api"
})

;