Search code examples
phplaravelfilesystemslaravel-jetstream

Laravel jetstream does not load profile photo


i create new laravel 9 proj with jetstream/inertia

laravel new testProject
cd testProject
composer require laravel/jetstream
php artisan jetstream:install inertia
npm install
npm run dev
php artisan serve

all i do with project is setting db access in .env file and uncommenting profilePhotos feature

'features' => [
        // Features::termsAndPrivacyPolicy(),
         Features::profilePhotos(),
        // Features::api(),
        // Features::teams(['invitations' => true]),
        Features::accountDeletion(),
    ],

also i run

php artisan storage:link

everythig looks ok, but after loading profile photo in profile information form it appears till page will be reloaded. After reloading i see my fullname and icon of unfounded image. In top right corner of the header i see same thing. In browser i see error message

Failed to load resource: the server responded with a status of 404 (Not Found)

page tries to load image from

storage/profile-photos/P2Fr1yHE0UenDAo5REUWEEWFcwq7esjLu0loP9Xa.png

In my project image saved in

storage/app/public/profile-photos/P2Fr1yHE0UenDAo5REUWEEWFcwq7esjLu0loP9Xa.png

and linked to public folder

public/storage/profile-photos/P2Fr1yHE0UenDAo5REUWEEWFcwq7esjLu0loP9Xa.png

i do not understand why my photo is not loaded from right directory.


Solution

  • i have found a solution. In vendor/laravel/jetstream/src/HasProfilePhoto.php in profilePhotoUrl function i changed

    ? Storage::disk($this->profilePhotoDisk())->url($this->profile_photo_path)
    

    to

    ? Storage::disk(config('profile_photos_disk'))->url($this->profile_photo_path)
    

    as i understood, $this->profilePhotoDisc() returns wrong answer, even if i just replace it with 'local' it is working, so im litle bit confused, but finally it works