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

mungurs's avatar

Missing port number in URL to storage files

Hello!

I'm running PHP 7.1 artisan serve on Bash on Ubuntu on Windows 10. Laravel 5.4 Artisan server runs on 8080 port. Problem is that all generated file URL's to storage dir are missing port. URL's are generated using http://glide.thephpleague.com , that uses League\Flysystem\Filesystem

Example of invalid url: http://127.0.0.1/storage/images/cache/429778df261630fee90a50f72b9e4a53ed6f27a0/f0b31b47c5443d19bded64cfecf0e032.jpg

Adding manually port to URL loads the image.

APP_URL as I understand is for CLI commands only, so no use of it in this situation. Tested the setup on macOS Sierra 10.12 and URL's are generated with port number and files load correctly,

Am I missing something?

1 like
1 reply
bluedreamer's avatar

Well I found this question which was my issue, I also found the answer which I'll post here for other.

In config/filesystems.php - change the 'url' setting to including APP_PORT from the env if it is set

'url' => env('APP_URL') . (env('APP_PORT') ? ':' . env('APP_PORT') : '') . '/storage',

Please or to participate in this conversation.