skip to Main Content

I’m maintaining an old app that I created when I first started using Laravel (ver 7.x) a couple of years ago. In production, it is hosted on a shared server.

Recently, I moved from WAMP to Docker for my local development environment. Back then, I wasn’t aware of the storage:link command, so URLs for some CSS and JS files were structured like this:

<link href="{{asset('storage/app/public/assets/css/style.css')}}" rel="stylesheet">
<script src="{!! asset('storage/app/public/assets/js/settings.js') !!}"></script>

And everything works perfect on production server ( shared server) and worked on local environment on WAMP setup.

However, when I switched to Docker, the storage folder became inaccessible. I considered refactoring the code to use storage:link, but unfortunately, storage:link doesn’t work on my shared server.

So, I decided to leave it as it is until I move the app to a VPS. The problem is that I can’t get these URLs to work locally in Docker. I’m wondering how they work in production, so there must be a way to make it work. I searched the web but couldn’t find any clues on how to do it. Do you have any ideas?

2

Answers


  1. Chosen as BEST ANSWER

    If anyone encounter this. I have found the solution by creating storage link locally like this config/filesystems.php

    'links' => [
        public_path('storage') => storage_path(''),
    ],
    

  2. Looks like this issue

    For it to work the Nginx container must have access to the storage folder, since it is supposed to serve assets that are located there. I’m guessing that is currently not the case and only the public folder is mounted.

    Check if the entire project or both ./public and ./storage are mounted into the Nginx container.

    Something like this:

    services:
      #...
      nginx:
       #...
       volumes:
        - "./public:/var/www/html/public:ro"
        - "./storage/app:/var/www/html/storage/app:ro"
        #...
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search