Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

carpad88's avatar

Problems with middleware and request to files

Hi people,

I have the following route

Route::middleware('auth')
    ->get('files/{any}', [MediaController::class, 'showFile'])
    ->where('any', '.*');

When trying to access this url

http://mypage.com/files/books/covers/book-124343-thum.jpg

I got redirected to the index and logged out of the app, it seems the url doesn't reach the controller. I'm using valet on my local environment and there works great, the problem comes when the site is deploy to a server on cloudways.

0 likes
2 replies
carpad88's avatar

Hi @automica

I change my current domain by mypage.com to give an idea of the url I'm visiting.

Please or to participate in this conversation.