"app.js failed to load" - Issues
Currently, this package works fine locally as can be seen here:

But upon deploying to a server and attempting to view the log files via {app-url}/log-viewer, this error arises:

This is an error in console:
Mixed Content: The page at '{url}/log-viewer' was loaded over HTTPS, but requested an insecure stylesheet '{url}/vendor/log-viewer/app.css?id=2d577fa607de6eeef7cfb84d3b72b864'. This request has been blocked; the content must be served over HTTPS.
I have attempted various things from within the server:
- php artisan vendor:publish --tag=log-viewer-assets --force
- php artisan log-viewer:publish
But the error still remains, any help would greatly be appreciated!
Hey, what's the value of APP_URL in your .env file?
I feel like it's simple HTTP, but should be HTTPS
@benbelmour just tagging you here in case you didn't see the above comment :)
Hello, I have the same issue, but I have my APP_URL using https already.
I added code in AppServiceProvider boot() method, As reference from this post: https://stackoverflow.com/questions/34378122/load-blade-assets-with-https-in-laravel
if(config('app.env') === 'production') {
\URL::forceScheme('https');
}
This solved the issue, but not sure if it is a fine solution.
Hey @benbelmour @LHongy
Laravel automatically guesses the scheme from the incoming request, but if your app is behind a proxy, Docker container, or some other indirect configuration, it might not get it correctly.
For this to work, you then need to define the asset URL manually in your .env
ASSET_URL=https://example.com
Hope this helps!
In the past adding the ASSET_URL used to fix it but seems it has returned now :( with app.css being the culprit app.css failed to load. Please refresh the page, re-publish Log Viewer assets, or fix routing for vendor assets.
@cAstraea Hey, please share the network tab in browser dev tools, especially the app.js and app.css requests. Thanks!
I am having the same problem. I have a client that is using a load balancer, and the log-viewer page shows the error: app.css failed to load. Please refresh the page, re-publish Log Viewer assets, or fix routing for vendor assets.
We've already added APP_URL and ASSET_URL to the .env file
Also when looking to the assets in the networks tab, the assets that are loading correctly in other pages are pointing correctly like this: /{site}/build/assets/app.css.
But inside the log-viewer page it is pointing like this: /{site}/vendor/log-viewer/app.css?id={numbers}. The correct path would be something like vendor/log-viewer/public/app.css ?
I've ommited some date putting it inside brackets.
Same problem here, trying to show the log on a local env.
Already modified APP_URL and added ASSET_URL with the same data but still get
I have tried both http and https but I keep getting the same error
The commands I executed are:
composer require opcodesio/log-viewerphp artisan log-viewer:publishphp artisan vendor:publish --tag="log-viewer-config"
Laravel 9 with PHP 8.3.7
@xYvanB what does your application's public folder look like? Does it have a vendor folder and within it a log-viewer folder with JS and CSS files?
public
└ vendor
└ log-viewer
└ app.js
└ app.css
If you have that, the next step is to make sure your http server actually serves all content from the public folder. For that I don't have any instructions since there's so many ways to run a PHP application behind http, but that's just an idea of what you could check.