zadam / trilium

Build your personal knowledge base with Trilium Notes
GNU Affero General Public License v3.0
26.74k stars 1.86k forks source link

(Bug report) Creating new PWAs broken when behind reverse proxy #4466

Open LokiLuciferase opened 9 months ago

LokiLuciferase commented 9 months ago

Trilium Version

0.62.2

What operating system are you using?

Other Linux

What is your setup?

Server access only

Operating System Version

Debian 12

Description

Hello,

Starting with 0.62.2, new PWAs created with either Chromium on desktop or Android, or Firefox on Android don't work for me.

Steps to reproduce: 1) Have trilium exposed to the web via an nginx reverse proxy such that https://mydomain.com/trilium gets redirected internally to https://<trilium IP>:<trilium port>, as shown in https://github.com/zadam/trilium/wiki/Server-installation#reverse-proxy-setup. 2) attempt to create a PWA with Chromium

Expected result: The newly created PWA works as previously

Actual result: The newly created PWA does not have an icon, and works only initially, but upon starting it from the OS, it instead points to the base of my domain (mydomain.com/).

I traced the issue to this change: https://github.com/zadam/trilium/pull/4371 which modified the webmanifest (in principle a great change, finally PWA support also in Firefox on Android!).

I managed to fix this in my trilium container by changing the absolute paths in the webmanifest to relative paths. Namely, the following works for me (and retains the ability to Install... in Firefox for Android):

...
  "scope": "./",
  "start_url": "./",
  "icons": [
    {
      "src": "assets/vX/images/app-icons/ios/apple-touch-icon.png",
      "sizes": "180x180",
      "type": "image/png"
    },
    {
      "src": "assets/vX/images/app-icons/png/512x512.png",
...

edit: seems like with the above config the PWA throws an error upon creation in Firefox for Android, but afterwards works flawlessly (separate task in task view, correct icon, and no URL bar)

zadam commented 9 months ago

Maybe @rauenzi ?

zerebos commented 9 months ago

I should be able to look into it this weekend, pwa documentation I've looked at is... Conflicting about absolute vs relative.