log-viewer icon indicating copy to clipboard operation
log-viewer copied to clipboard

"app.js failed to load" - Issues

Open benbelmour opened this issue 3 years ago • 10 comments

Currently, this package works fine locally as can be seen here:

image

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

image

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!

benbelmour avatar Mar 09 '23 14:03 benbelmour

Hey, what's the value of APP_URL in your .env file?

I feel like it's simple HTTP, but should be HTTPS

arukompas avatar Mar 09 '23 19:03 arukompas

@benbelmour just tagging you here in case you didn't see the above comment :)

arukompas avatar Mar 10 '23 14:03 arukompas

Hello, I have the same issue, but I have my APP_URL using https already.

LHongy avatar Mar 17 '23 07:03 LHongy

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.

LHongy avatar Mar 17 '23 07:03 LHongy

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!

arukompas avatar Mar 19 '23 11:03 arukompas

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 avatar Mar 21 '24 01:03 cAstraea

@cAstraea Hey, please share the network tab in browser dev tools, especially the app.js and app.css requests. Thanks!

arukompas avatar Mar 21 '24 07:03 arukompas

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.

Jexraiden avatar Jul 11 '24 13:07 Jexraiden

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 image

I have tried both http and https but I keep getting the same error image

The commands I executed are:

  • composer require opcodesio/log-viewer
  • php artisan log-viewer:publish
  • php artisan vendor:publish --tag="log-viewer-config"

Laravel 9 with PHP 8.3.7

xYvanB avatar Jul 30 '24 08:07 xYvanB

@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.

arukompas avatar Jul 30 '24 17:07 arukompas