MichaIng / DietPi

Lightweight justice for your single-board computer!
https://dietpi.com/
GNU General Public License v2.0
4.9k stars 499 forks source link

Koel not working anymore after updating to version 7.0.2 #7155

Closed bartolus39 closed 2 months ago

bartolus39 commented 4 months ago

Creating a bug report/issue

Required Information

Additional Information (if applicable)

Steps to reproduce

  1. Update/install koel
  2. visit the webpage at x.x.x.x:8003

Actual behaviour

The webpage is saying "Untrusted Host" image

further down: image

Extra details

MichaIng commented 4 months ago

Does clearing the browser cache help, e.g. with a forced page reload CTRL+C? And did/do you have HTTPS enabled for Koel? Trusted hosts seem to be set/checked only when HTTPS is enforced: https://github.com/koel/koel/blob/master/app/Http/Middleware/ForceHttps.php

MichaIng commented 4 months ago

I can replicate it. It works on a fresh install, but upgrading from v6 to v7 leads to this error. Erasing all browser data does not help, it must be some database migration issue.

EDIT: Okay strange. I wanted to compare the database, hence uninstalled and reinstalled Koel, but now it still throws the error. It did work well when I installed v7 initially. Weird.

MichaIng commented 4 months ago

Okay, not sure why it did work well on my very first attempt. Now, I cannot get it working anymore with fresh installs on any system or with any other browser.

But I found out one way to get it working: In the config file /mnt/dietpi_userdata/koel/.env, change the host in APP_URL from localhost to the IP or hostname you use to access Koel. The port number does not matter, not even the protocol does, but the host only. That one seems to be added to the list of trusted hosts now. The question is how other hosts can be added to this list.

... another problem: Now most UI elements are not functional. In browser console I see an error:

TypeError: Cannot read properties of undefined (reading 'register')
bartolus39 commented 4 months ago

Thanks a lot for your efforts!! I am seeing now same behavior. With changing the APP_URL it loads the page, but no UI elements. I put it also into an apache webserver. This gives the same problem. However, putting it into a "real" webserver environment (with access from outside home with DDNS, with https...) it loads the UI elements. Maybe the access via https makes the difference?

MichaIng commented 4 months ago

Yes, I guess that there is something messed up with these trusted host checks. Since there is no (documented) way to append to this list it must not be checked, but it is. Likely, internal URLs/requests generated by the backend to load further assets, are also affected by this, and hence fail for the same reason, unless one indirectly adds another entry by enforcing HTTPS. The script I posted above then adds the current client request host to the list of trusted hosts explicitly, and I guess also Koel itself then generates URLs internally differently.

There was a PR to change the behaviour around this: https://github.com/koel/koel/pull/1706 But as can be seen, it was reverted later. Looks like it was again implemented, probably a different way, but still breaks things. I know this in general from ownCloud and Nextcloud: In their configs, you can define an array with all trusted hosts (including a wildcard * to disable the feature), and a CLI URL, to be used by requests from the backend itself. Koel however does not have any of these, at least not documented, hence this cannot go well. Maybe Laravel itself actually does support it.

We need to report this to the Koel: https://github.com/koel/koel/issues Let me do this, since I can list the steps how we install Koel (still all right, according to docs), and hence an easy way to replicate.

MichaIng commented 4 months ago

There have been several updates, now v7.0.6, but the issue persists. Reported here: https://github.com/koel/koel/issues/1796

bartolus39 commented 4 months ago

I tried out the v7.0.6 now, and here it is now working as expected. So all UI elements are visible and seem to work. What is the difference to your setup?

MichaIng commented 4 months ago

We found the reason and a nice way to make the trusted hosts feature transparently available, but allow all hosts by default (pre-v7.0.0 behaviour): https://github.com/koel/koel/pull/1797

And you are right, the missing GUI elements work fine here as well. I missed to test this with the latest version.

MichaIng commented 2 months ago

This has been released with Koel v7.0.10

Update via reinstall:

dietpi-software reinstall 143