最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Laravel 11 media library styles.css link incorrect - Stack Overflow

programmeradmin0浏览0评论

I have a Laravel 11 app in a docker container that fails to load the styles.css file from Spaite's Media Library Pro.

The URL it calls for is:

Request URL: http://localhost/media-library-pro/styles.css. <- incorrect

The referrer however is correct:

Referrer: / <- correct

How do I fix that? All other resources load fine.

In the .env I have: APP_URL= and that's what I access the project with. I also have the APP_ENV=local set.

I've run: php artisan config:clear and php artisan config:cache and php artisan storage:link

The output of echo config('app.url'); is:

The rest of Media library pro works fine, images upload and previews display.

What else can I do or check to see where it's getting http://localhost from?

The controller that outputs the link is:

class MediaLibraryStylesController
{
    public function __invoke()
    {
        //        $styles = File::get(__DIR__ . '../resources/js/media-library-pro-styles/dist/styles.css');

        $styles = File::get(__DIR__.'/../../../resources/js/media-library-pro-styles/dist/styles.css');
        $contents = <<<html
                   $styles
            html;

        return response()->make($contents)->header('Content-Type', 'text/css');
    }
}

The styles.css file is in that location.

I have a Laravel 11 app in a docker container that fails to load the styles.css file from Spaite's Media Library Pro.

The URL it calls for is:

Request URL: http://localhost/media-library-pro/styles.css. <- incorrect

The referrer however is correct:

Referrer: http://local.myproject/ <- correct

How do I fix that? All other resources load fine.

In the .env I have: APP_URL=http://local.myproject and that's what I access the project with. I also have the APP_ENV=local set.

I've run: php artisan config:clear and php artisan config:cache and php artisan storage:link

The output of echo config('app.url'); is: http://local.myproject

The rest of Media library pro works fine, images upload and previews display.

What else can I do or check to see where it's getting http://localhost from?

The controller that outputs the link is:

class MediaLibraryStylesController
{
    public function __invoke()
    {
        //        $styles = File::get(__DIR__ . '../resources/js/media-library-pro-styles/dist/styles.css');

        $styles = File::get(__DIR__.'/../../../resources/js/media-library-pro-styles/dist/styles.css');
        $contents = <<<html
                   $styles
            html;

        return response()->make($contents)->header('Content-Type', 'text/css');
    }
}

The styles.css file is in that location.

Share Improve this question asked Nov 20, 2024 at 3:25 polycodepolycode 2352 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Ugh. This must've been a view cache issue.

I deleted the @mediaLibraryStyles blade directive, viewed the site, added it back and this time the url was correct.

发布评论

评论列表(0)

  1. 暂无评论