The middleware.ts not working in custom app directory
Answered
Turkey Vulture posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Turkey VultureOP
the middleware is on the root directory of app but it not working. if i moved into src it worked. so weird
Answered by Z4NR34L
if you are using app directory at root, migrate everything out from src, or opposite, your middleware.ts should be always in same level as app or pages directory (if you use src dir, put it inside)
5 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Turkey VultureOP
![Image](https://cdn.discordapp.com/attachments/1176500396131365015/1176500802857222216/Screenshot_2023-11-21_at_8.32.59_PM.png?ex=656f18c1&is=655ca3c1&hm=04285be2045f8850bf64642fd342118a7a343097845d6887fbfa4678cff3ac8a&)
![Avatar](https://cdn.discordapp.com/avatars/289522409088876546/9422498062d396ce258b03083453c8c4.webp?size=256)
Z4NR34L
You can have src or app directory, never both in same tree level
![Avatar](https://cdn.discordapp.com/avatars/289522409088876546/9422498062d396ce258b03083453c8c4.webp?size=256)
Z4NR34L
if you are using app directory at root, migrate everything out from src, or opposite, your middleware.ts should be always in same level as app or pages directory (if you use src dir, put it inside)
Answer
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Turkey VultureOP
ah thanks @Z4NR34L
![Avatar](https://cdn.discordapp.com/avatars/289522409088876546/9422498062d396ce258b03083453c8c4.webp?size=256)
Z4NR34L
No problem! If that solved your problem, please mark a message as the answer for your post with
Right click -> Apps -> Mark Solution