Why my laravel development server doesnt serve files under public folder?

I am using Spatie for images. I have the current public definition on my filesystems.php as:

'public' => [
    'driver' => 'local',
    'root'   => public_path().'/media',
    'url' => env('APP_URL').'/public/media',
    'visibility' => 'public',
]

Which gives me links as
http://localhost:8000/public/media/3/profile_3.png

When I enter this URL into the browser, the Laravel server responds with 404 even though the profile_3.png file is in the public/media/3/ directory on the server.

What could be the problem in my case? thank you.

I tried different combinations, and it still doesn’t work.

>Solution :

Update filesystems.php.

'public' => [
    'driver' => 'local',
    'root' => public_path().'/media',
    'url' => env('APP_URL').'/media', // Remove '/public' from the URL
    'visibility' => 'public',
]

Then clear the config cache after making changes to filesystems.php:

php artisan config:cache

Then try accessing the image at:

http://localhost:8000/media/3/profile_3.png

Leave a Reply