How to resolve this dependency in the hangfire?

In my application some of dependencies for services get resolved in middleware so attributes on the appContext can be changed frequently from the client side.

However when registering the job and job get executed appContext’s dependency don’t get resolved because it doesn’t go though middleware. How can I do it in order to resolve dependency?

==class MyMiddleware====
public async Task Invoke(HttpContext httpContext, AppContext appContext)

ServiceA(AppContext appContext, DBContext dbContext)
ServiceB(AppContext appContext, DBContext dbContext)