Fix custom routes middleware