okay i think this middleware is finally actually working all the time pretty much