If you use 'src' and 'app' directory make sure to keep your middleware file OUTSIDE the app but inside 'src'