Laravel-Backpack / basset

Better asset helpers for Laravel apps.
MIT License
151 stars 10 forks source link

Laravel Backpack (basset) not working in docker with nginx #130

Closed IlyaBuldakov closed 1 month ago

IlyaBuldakov commented 1 month ago

I use laravel backpack and everything works when I start the server using php artisan serve, and then use the admin panel at localhost:8000/admin.

But as soon as I run docker(nginx + php fpm (here is backpack) + mysql) it stops working!

Okay, you tell me that basset is trying to use a local path and it is. My next step is to replace APP_ENV=local with APP_ENV=production (yes, that's exactly what I need). This way I achieve that backpack finds all the necessary files, but the page is displayed WITHOUT STYLES and other resources. Here is screenshots for case "APP_ENV=production, APP_URL=http://nginx"

image image image

Here is my nginx.conf:

`events {

} http { server { listen 80; server_name localhost; root /var/www/next/public;

    index index.php;

    location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
            access_log off;
            expires max;
            log_not_found off;
    }

    location / {
            try_files $uri $uri/ /index.php?$query_string;
    }

    location ~* \.php$ {
    try_files $uri = 404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass php-fpm:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

location ~ /\.ht {
            deny all;
    }

} }`

and here is my docker-compose.yml

` version: "3"

services: nginx: image: nginx ports:

I've been doing this for the 3rd day and I really need help :( Thanks everyone

pxpm commented 1 month ago

I believe this is fixed in https://github.com/Laravel-Backpack/CRUD/issues/5526

Please re-open if I am wrong and we can have a look at it again 🙏