jeffvli / feishin

A modern self-hosted music player.
https://feishin.vercel.app
GNU General Public License v3.0
1.99k stars 78 forks source link

Configure a fixed server for the docker web app #380

Closed haath closed 4 months ago

haath commented 7 months ago

Hey all,

To make it easier for my users, I'd like to set up a Feishin front-end that is configured to already have the URL of my Jellyfin server. Then users visiting the Feishin web app would only be prompted to enter their Jellyfin credentials and log in.

In my opinion the current Open Menu > Manage servers flow is a bit redundant, and could be streamlined away when the intent is just to use one frontend with one backend.

On the Docker side, this could easily be configured by setting some JELLYFIN_URL or NAVIDROME_URL environment variable.

stefan1983 commented 7 months ago

+1

I ran into the same as well, when connecting from different network devices.

jeffvli commented 7 months ago

I did some preliminary work on getting this done in branch feature/#380. I can't seem to get the environment variables to pass from docker into the production build though.

If someone is familiar with this process can they take a look?

kgarner7 commented 7 months ago

Given that Dockerized NGINX supports templating, what's probably the easiest solution is to just have the web version serve an additional JavaScript file, generated by NGINX template itself.

location ${PUBLIC_PATH}/settings.js {
    add_header Content-Type application/javascript;
    return '"use strict";window.SERVER_URL="${SERVER_URL}";'
}

You could then tweak the index.ejs file to include this script first for web builds (and then use process.env.SERVER_URL, and fallback to window.SERVER_URL)

Kakoluz commented 6 months ago

I started working on this feature on my own a short while ago and left it somewhat hung. I have days off work this week and i will look into it. But the solution @kgarner7 proposes seems reasonable. its just matter of setting the docker image to replace envs with those passed to the container. Might also look into possible alternatives. Expect a PR related to this soonish.

Angablade commented 6 months ago

If you are using Nginx as a reverse proxy in front of everything, you can do something real simple to do this.

location = /renderer.js { sub_filter_once on; sub_filter_types *; sub_filter '({initialValues:{legacyAuth:!1,name:"",password:"",savePassword:!1,type:v.ServerType.JELLYFIN,url:"http://",username:""}})' '({initialValues:{legacyAuth:!1,name:"My Music",password:"",savePassword:!1,type:v.ServerType.JELLYFIN,url:"https://example.co.uk",username:""}})'; proxy_set_header Forwarded $proxy_add_forwarded; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://<IP>:9180/renderer.js; }

SamLawAnthro commented 4 months ago

location = /renderer.js { sub_filter_once on; sub_filter_types *; sub_filter '({initialValues:{legacyAuth:!1,name:"",password:"",savePassword:!1,type:v.ServerType.JELLYFIN,url:"http://",username:""}})' '({initialValues:{legacyAuth:!1,name:"My Music",password:"",savePassword:!1,type:v.ServerType.JELLYFIN,url:"https://example.co.uk",username:""}})'; proxy_set_header Forwarded $proxy_add_forwarded; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://:9180/renderer.js; }

where would i add this in the ngnix configs??

Angablade commented 4 months ago

in the configs you use for feishin. feel free to reach out to me on discord if you need help!