Your problem was the default APP_URL setting in .env file:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:6IJbdi+QYczKeLT7yOw3OgPsHucXn1KxVUb27hTQKpU=
APP_DEBUG=true
APP_URL=http://localhost
The artisan serve command launched the app on http://127.0.0.1:8000, so you changed the APP_URL correspondingly:
APP_URL=http://127.0.0.1:8000
I wouldn't recommend this. Sometimes, for various reasons, the command could change the port to 8001, 8002, etc.
$ php artisan serve
Starting Laravel development server: http://127.0.0.1:8000
Failed to listen on 127.0.0.1:8000 (reason: Address already in use)
Starting Laravel development server: http://127.0.0.1:8001
PHP 7.4.12 Development Server (http://127.0.0.1:8001) started
Simple solution
Just comment or leave the APP_URL in your .env file empty:
#APP_URL=http://localhost
APP_URL=
This will remove the http://localhost part from profile images and solve the problem:
<img src="/storage/profile-photos/photo.jpeg">
You will have different .env file in production environment anyway.
Additionally
You made a small change in your config/filesystems.php file:
'public' => [
'driver' => 'local',
'root' => storage_path('/public/storage'),
'url' => env('APP_URL').'/public/storage/',
'visibility' => 'public',
],
The original setting was:
'root' => storage_path('/app/public'),
It worked only after you have deleted and rebuilded the symlink.
But now, in your project directory, you probably have a situation like this:
- public - storage
+ css - app
+ js - public
- storage - profile-photos
- public - public
- storage - storage
- profile-photos - profile-photos
.htaccess + framework
favicon.ico + logs
index.php
mix-manifest.json
robots.txt
web.config
Basically, you made a new disk. I presume this wasn't intentional.
Also, your profile photos probably have a bit confusing part in their url:
.../storage/public/storage/profile-photos/....
You could revert to original setting, delete the additional folder, and rebuild the sysmlink.
config/filesystems.php
'disks' => [
//...
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
//...
],