Fix middleware injection