CyferShepard / Jellystat

Jellystat is a free and open source Statistics App for Jellyfin
MIT License
1.09k stars 32 forks source link

Can’t update Jellyfin URL and API values in Settings ? #248

Open nodecentral opened 1 month ago

nodecentral commented 1 month ago

Describe the bug

Changes being made to the settings are not being saved, even though Update has been pressed (and occasional a save successfully message comes up)

Environment Details (please complete the following information):

To Reproduce Steps to reproduce the behavior:

  1. Go to '.Settings update Jellyfin URL and API Key'
  2. Click on 'Update.'
  3. Refresh the browser '
  4. Settings are not changed

Expected behavior Settings should be saved

Screenshots

image

Task Logs

http://192.168.102.134:8096/ true
http://192.168.102.134:8096/ true
http://192.168.102.134:8096/ true
http://192.168.102.134:8096/ true
[JELLYFIN-API] {
  ErrorAt: 'at JellyfinAPI.getAdmins (/app/backend/classes/jellyfin-api.js:118:21',
  ErrorLines: [
    {
      TraceIndex: 1,
      line: '/app/backend/classes/jellyfin-api.js:118:21'
    },
    { TraceIndex: 2, line: 'node:internal/process/task_queues:95:5' },
    {
      TraceIndex: 3,
      line: 'at async /app/backend/routes/proxy.js:146:23'
    }
  ],
  Message: 'users?.filter is not a function',
  url: undefined
nodecentral commented 1 month ago

Hi @CyferShepard - do you need anything more from me on this issue ?

Is there anything I can do in the interim ? The Jellyfin ip and port, it gave me is the one I set up for jelly stat, and no matter what I can do I can’t edit it. Is there somewhere like a config/txt/xml file where I could maybe edit it in ?

CyferShepard commented 1 month ago

Hey @nodecentral , can you pull the newest unstable image and try again? i added safety checks for the code where the logs indicated an error. I just want to see if that helps or if theres a new error

nodecentral commented 1 month ago

Hi - OK - pulled the unstable version and tried to make changes to the Jelly fin URL and API key again..

No message comes up, and upon refresh the it returns to it’s original value - so the problem still occurs.. Here is a snap of the log..

> jfstat@1.1.1 start
> cd backend && node server.js
all values are hidden
env.js file has been saved successfully.
[JELLYSTAT] Database exists. Skipping creation
FS-related option specified for migration configuration. This resets migrationSource to default FsMigrations
FS-related option specified for migration configuration. This resets migrationSource to default FsMigrations
[JELLYSTAT] Server listening on http://127.0.0.1:3000/
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="theme-color" content="#000000" />
    <meta name="description" content="Jellyfin stats for the masses" />
    <link rel="apple-touch-icon" href="icon-b-192.png" />
    <script src="env.js"></script>
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.
all values are hidden
      Unlike "favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>JellyStat</title>
    <script type="module" crossorigin src="./assets/index-864c1f9d.js"></script>
    <link rel="modulepreload" crossorigin href="./assets/vendor-2d4d1dd6.js">
    <link rel="stylesheet" href="./assets/index-ac22111c.css">
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>

  </body>
</html>
all values are hidden
[JELLYFIN-API] {
  ErrorAt: 'at JellyfinAPI.getRecentlyAdded (/app/backend/classes/jellyfin-api.js:355:48',
  ErrorLines: [
    {
      TraceIndex: 1,
      line: '/app/backend/classes/jellyfin-api.js:355:48'
    },
    { TraceIndex: 2, line: 'node:internal/process/task_queues:105:5' },
    {
      TraceIndex: 3,
      line: 'at async /app/backend/routes/api.js:170:38'
    }
  ],
  Message: "Cannot read properties of undefined (reading 'Id')",
  url: undefined
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="theme-color" content="#000000" />
    <meta name="description" content="Jellyfin stats for the masses" />
    <link rel="apple-touch-icon" href="icon-b-192.png" />
    <script src="env.js"></script>
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.
all values are hidden
      Unlike "favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>JellyStat</title>
    <script type="module" crossorigin src="./assets/index-864c1f9d.js"></script>
    <link rel="modulepreload" crossorigin href="./assets/vendor-2d4d1dd6.js">
    <link rel="stylesheet" href="./assets/index-ac22111c.css">
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>

  </body>
</html>
all values are hidden
http://192.168.102.134:8096/ true
http://192.168.102.134:8096/ true
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="theme-color" content="#000000" />
    <meta name="description" content="Jellyfin stats for the masses" />
    <link rel="apple-touch-icon" href="icon-b-192.png" />
    <script src="env.js"></script>
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.
all values are hidden
      Unlike "favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>JellyStat</title>
    <script type="module" crossorigin src="./assets/index-864c1f9d.js"></script>
    <link rel="modulepreload" crossorigin href="./assets/vendor-2d4d1dd6.js">
    <link rel="stylesheet" href="./assets/index-ac22111c.css">
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>

  </body>
</html>
all values are hidden
[JELLYFIN-API] {
  ErrorAt: 'at AxiosError.from (/app/node_modules/axios/dist/node/axios.cjs:841:14',
  ErrorLines: [
    {
      TraceIndex: 1,
      line: '/app/node_modules/axios/dist/node/axios.cjs:841:14'
    },
    {
      TraceIndex: 2,
      line: '/app/node_modules/axios/dist/node/axios.cjs:3106:25'
    },
    { TraceIndex: 3, line: 'node:events:520:28' },
    {
      TraceIndex: 4,
      line: '/app/node_modules/follow-redirects/index.js:38:24'
    },
    { TraceIndex: 5, line: 'node:events:520:28' },
    { TraceIndex: 6, line: 'node:_http_client:103:11' },
    { TraceIndex: 7, line: 'node:_http_client:506:5' },
    { TraceIndex: 8, line: 'node:events:520:28' },
    { TraceIndex: 9, line: 'node:internal/streams/destroy:170:8' },
    { TraceIndex: 10, line: 'node:internal/streams/destroy:129:3' },
    {
      TraceIndex: 11,
      line: '/app/node_modules/axios/dist/node/axios.cjs:4224:41'
    },
    { TraceIndex: 12, line: 'node:internal/process/task_queues:105:5' },
    {
      TraceIndex: 13,
      line: '/app/backend/classes/jellyfin-api.js:486:24'
    },
    {
      TraceIndex: 14,
      line: 'at async /app/backend/routes/api.js:279:24'
    }
  ],
  Message: 'connect ETIMEDOUT 192.168.102.134:8096',
  url: undefined
}
[JELLYFIN-API] {
  ErrorAt: 'at AxiosError.from (/app/node_modules/axios/dist/node/axios.cjs:841:14',
  ErrorLines: [
    {
      TraceIndex: 1,
      line: '/app/node_modules/axios/dist/node/axios.cjs:841:14'
    },
    {
      TraceIndex: 2,
      line: '/app/node_modules/axios/dist/node/axios.cjs:3106:25'
    },
    { TraceIndex: 3, line: 'node:events:520:28' },
    {
      TraceIndex: 4,
      line: '/app/node_modules/follow-redirects/index.js:38:24'
    },
    { TraceIndex: 5, line: 'node:events:520:28' },
    { TraceIndex: 6, line: 'node:_http_client:103:11' },
    { TraceIndex: 7, line: 'node:_http_client:506:5' },
    { TraceIndex: 8, line: 'node:events:520:28' },
    { TraceIndex: 9, line: 'node:internal/streams/destroy:170:8' },
    { TraceIndex: 10, line: 'node:internal/streams/destroy:129:3' },
    {
      TraceIndex: 11,
      line: '/app/node_modules/axios/dist/node/axios.cjs:4224:41'
    },
    { TraceIndex: 12, line: 'node:internal/process/task_queues:105:5' },
    {
      TraceIndex: 13,
      line: '/app/backend/classes/jellyfin-api.js:486:24'
    },
    {
      TraceIndex: 14,
      line: 'at async /app/backend/routes/api.js:279:24'
    }
  ],
  Message: 'connect ETIMEDOUT 192.168.102.134:8096',
  url: undefined

It seems to be reporting the IP I had updated it to, here in the logs, but when I hit refresh on the Settings screen it just shows me to original one which has 8097 as the port (FYI - this is the port that I set Jellystat to)

nodecentral commented 1 month ago

Just to share the sequence..

After I make the change to the Jellyfin URL and API key I hit Update, and the log shows the following..

http://192.168.102.134:8096/ true

From there, I then hit refresh of the browser to see if it has saved, and then it gives me the following messages in the log - alluding to a javascript setting - FYI I’m using an iPAD (and Safari)

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="theme-color" content="#000000" />
    <meta name="description" content="Jellyfin stats for the masses" />
    <link rel="apple-touch-icon" href="icon-b-192.png" />
    <script src="env.js"></script>
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.
all values are hidden
      Unlike "favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>JellyStat</title>
    <script type="module" crossorigin src="./assets/index-864c1f9d.js"></script>
    <link rel="modulepreload" crossorigin href="./assets/vendor-2d4d1dd6.js">
    <link rel="stylesheet" href="./assets/index-ac22111c.css">
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>

  </body>
</html>

I checked my settings and javascript is enabled.,

image
nodecentral commented 1 month ago

Just to be sure you have all the information you need from my logs, he’s what’s occurred since my last failed saves ..


    { TraceIndex: 6, line: 'node:_http_client:103:11' },
    { TraceIndex: 7, line: 'node:_http_client:506:5' },
    { TraceIndex: 8, line: 'node:events:520:28' },
    { TraceIndex: 9, line: 'node:internal/streams/destroy:170:8' },
    { TraceIndex: 10, line: 'node:internal/streams/destroy:129:3' },
    {
      TraceIndex: 11,
      line: '/app/node_modules/axios/dist/node/axios.cjs:4224:41'
    },
    { TraceIndex: 12, line: 'node:internal/process/task_queues:105:5' },
    {
      TraceIndex: 13,
      line: '/app/backend/classes/jellyfin-api.js:486:24'
    },
    {
      TraceIndex: 14,
      line: 'at async /app/backend/routes/api.js:279:24'
    }
  ],
  Message: 'connect ETIMEDOUT 192.168.102.134:8096',
  url: undefined
}
[JELLYFIN-API] {
  ErrorAt: 'at AxiosError.from (/app/node_modules/axios/dist/node/axios.cjs:841:14',
  ErrorLines: [
    {
      TraceIndex: 1,
      line: '/app/node_modules/axios/dist/node/axios.cjs:841:14'
    },
    {
      TraceIndex: 2,
      line: '/app/node_modules/axios/dist/node/axios.cjs:3106:25'
    },
    { TraceIndex: 3, line: 'node:events:520:28' },
    {
      TraceIndex: 4,
      line: '/app/node_modules/follow-redirects/index.js:38:24'
    },
    { TraceIndex: 5, line: 'node:events:520:28' },
    { TraceIndex: 6, line: 'node:_http_client:103:11' },
    { TraceIndex: 7, line: 'node:_http_client:506:5' },
    { TraceIndex: 8, line: 'node:events:520:28' },
    { TraceIndex: 9, line: 'node:internal/streams/destroy:170:8' },
    { TraceIndex: 10, line: 'node:internal/streams/destroy:129:3' },
    {
      TraceIndex: 11,
      line: '/app/node_modules/axios/dist/node/axios.cjs:4224:41'
    },
    { TraceIndex: 12, line: 'node:internal/process/task_queues:105:5' },
    {
      TraceIndex: 13,
      line: '/app/backend/classes/jellyfin-api.js:486:24'
    },
    {
      TraceIndex: 14,
      line: 'at async /app/backend/routes/api.js:279:24'
    }
  ],
  Message: 'connect ETIMEDOUT 192.168.102.134:8096',
  url: undefined
}
[JELLYFIN-API] {
  ErrorAt: 'at AxiosError.from (/app/node_modules/axios/dist/node/axios.cjs:841:14',
  ErrorLines: [
    {
      TraceIndex: 1,
      line: '/app/node_modules/axios/dist/node/axios.cjs:841:14'
    },
    {
      TraceIndex: 2,
      line: '/app/node_modules/axios/dist/node/axios.cjs:3106:25'
    },
    { TraceIndex: 3, line: 'node:events:520:28' },
    {
      TraceIndex: 4,
      line: '/app/node_modules/follow-redirects/index.js:38:24'
    },
    { TraceIndex: 5, line: 'node:events:520:28' },
    { TraceIndex: 6, line: 'node:_http_client:103:11' },
    { TraceIndex: 7, line: 'node:_http_client:506:5' },
    { TraceIndex: 8, line: 'node:events:520:28' },
    { TraceIndex: 9, line: 'node:internal/streams/destroy:170:8' },
    { TraceIndex: 10, line: 'node:internal/streams/destroy:129:3' },
    {
      TraceIndex: 11,
      line: '/app/node_modules/axios/dist/node/axios.cjs:4224:41'
    },
    { TraceIndex: 12, line: 'node:internal/process/task_queues:105:5' },
    {
      TraceIndex: 13,
      line: '/app/backend/classes/jellyfin-api.js:486:24'
    },
    {
      TraceIndex: 14,
      line: 'at async /app/backend/routes/api.js:279:24'
    }
  ],
  Message: 'connect ETIMEDOUT 192.168.102.134:8096',
  url: undefined
  }
CyferShepard commented 1 month ago

Hey @nodecentral , just to confirm, this section, &lt;!DOCTYPE html&gt; &lt;html lang=&#34;en&#34;&gt; &lt;head&gt; &lt;meta charset=&#34;UTF-8&#34; /&gt; &lt;link rel=&#34;icon&#34; href=&#34;favicon.ico&#34; /&gt; &lt;meta name=&#34;viewport&#34; content=&#34;width=device-width, initial-scale=1.0&#34; /&gt; &lt;meta name=&#34;theme-color&#34; content=&#34;#000000&#34; /&gt; &lt;meta name=&#34;description&#34; content=&#34;Jellyfin stats for the masses&#34; /&gt; &lt;link rel=&#34;apple-touch-icon&#34; href=&#34;icon-b-192.png&#34; /&gt; &lt;script src=&#34;env.js&#34;&gt;&lt;/script&gt; &lt;!-- manifest.json provides metadata used when your web app is installed on a user&#39;s mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ --&gt; &lt;link rel=&#34;manifest&#34; href=&#34;manifest.json&#34; /&gt; &lt;!-- Notice the use of %PUBLIC_URL% in the tags above. It will be replaced with the URL of thepublicfolder during the build. Only files inside thepublicfolder can be referenced from the HTML. all values are hidden Unlike &#34;favicon.ico&#34; or &#34;favicon.ico&#34;, &#34;%PUBLIC_URL%/favicon.ico&#34; will work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by runningnpm run build`. --> <title>JellyStat</title> <script type="module" crossorigin src="./assets/index-864c1f9d.js"></script> <link rel="modulepreload" crossorigin href="./assets/vendor-2d4d1dd6.js"> <link rel="stylesheet" href="./assets/index-ac22111c.css"> </head> <body> <noscript>You need to enable JavaScript to run this app.</noscript> <div id="root"></div>

</body> </html>`

Does that appear in the docker logs or console logs?

nodecentral commented 1 month ago

Hi @CyferShepard - it's from the Docker logs.

The Jellystat logs sadly tell me very little, they only reference the sync and any backups - nothing more. No updates to settings seem to be recorded ?

image

CyferShepard commented 1 month ago

okay thanks, im not really sure how to replicate this so it may take me a while. can you try this but, change the api and url, then on another device, or even in incognito mode, go to the settings page and see if its still the old value or the new value

nodecentral commented 1 month ago

Sadly the same thing via Chrome and ingconito mode on the iPad

nodecentral commented 1 month ago

Hi @CyferShepard - is there anything else I can do to make this work, sadly I can’t use Jellystat until I can update the details. Is it perhaps in a config file I could manually access and change?

CyferShepard commented 1 month ago

Hey @nodecentral , sorry i didnt actually debug this in depth, i initially got stuck on trying to replicate the error. not really sure whats causing it or how to replicate it in my test instance. theres no config for this. the only way is to manually set the values in the postgres db

nodecentral commented 1 month ago

Thanks so much for responding @CyferShepard, if it's not something you can reproduce then I completely appreciate it's not something you'd want to spend time on..

To try one final things - as I never considered or even know where to state to edit a value in the postgres db before, do you know if that is that possible? I'll try anything to help get this to work :-)

CyferShepard commented 1 month ago

so i added 2 new environmental variables to allow you to override these values. it doesnt store it to the db, just replaces the db value when its being used. the new envs are called JF_HOST and JF_API_KEY. Just a heads up however. i dont have any validation on this field. and depending on the values you enter, if not formatted correctly. it could cause bugs or errors in the logs. an example of something that should work is JF_HOST : http://192.168.0.1:8096 JF_API_KEY: xxxxxxxxxxxxxxxxx

nodecentral commented 1 month ago

Many Thanks @CyferShepard

I’ll give it a go with the latest image you have ..


version: '3'

services:
  jellystat-db:
    image: postgres:15.2
    container_name: jellystat-db
    restart: unless-stopped
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: mypassword
    volumes:
      - /share/Container/jellystat/postgres-data:/var/lib/postgresql/data

  jellystat:
    image: cyfershepard/jellystat:latest
    container_name: jellystat
    restart: unless-stopped
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: mypassword
      POSTGRES_IP: jellystat-db
      POSTGRES_PORT: 5432
      JWT_SECRET: "my-secret-jwt-key"
      JF_HOST: http://192.168.1.234:8096
      JF_API_KEY: moienfoeifnoweifnwoeinfwoeifnwoeinf
      TZ: Europe/London
    volumes:
      - /share/Container/jellystat/jellystat-backup-data:/app/backend/backup-data
    ports:
      - "8097:3000"
    depends_on:
      - jellystat-db

networks:
  default:

volumes:
  postgres-data:
  jellystat-backup-data:

logging:
  driver: "json-file"
  options:
    max-file: "5" # number of files or file count
    max-size: "10m" # file size
```a
CyferShepard commented 4 weeks ago

Hey @nodecentral , its not on latest, it would be on unstable. Only new releases have the latest tag

nodecentral commented 4 weeks ago

Hi @CyferShepard

Sadly, no luck with the unstable version, even as environment variables they are not showing up. Ok, to try again from the start removed all web cache, delete all Postgres dbs - and even after that I can't get past it the initial 'validating' step?

image

The logs only show this..

image

It won't progress any further..

Any ideas are there more verbose logs I can check ?

CyferShepard commented 4 weeks ago

can you check he browsers console log? its located in your browsers dev tools

nodecentral commented 4 weeks ago

Sure, here you go, reminder my primary device is an iPad

image

I checked my Safaris settings and javascript is (and always has been) enabled.

image

Other entries of interest are as follows

image

It’s important to note, that both Jellyfin and jellystat are running on the same host 192.168.102.134, Jellyfin is port :8096 and jellystat is port :8097

I did try using local host (see below) but got a 400 error

image
CyferShepard commented 4 weeks ago

can you try host.docker.internal instead of localhost, so it would be http://host.docker.internal:8096

nodecentral commented 4 weeks ago

Same 400 error with http://host.docker.internal:8096/ as it was with http://127.0.0.1:8096/

image

If i try the actual Jellyfin IP, on http://192.168.102.134:8096/ it shows validating, but that’s it, nothing more it stays there.

image