Created a middleware but it cockblocked the logging out mechanism.