Xyphyn / photon

An opinionated web client for Lemmy to help users discover the fediverse.
https://phtn.app
GNU Affero General Public License v3.0
390 stars 43 forks source link

If SSR is enabled but no favicon is configured the container fails to start #310

Open poVoq opened 6 months ago

poVoq commented 6 months ago

Setting PUBLIC_SSR_ENABLED to true, but not setting anything for PUBLIC_FAVICON makes the container fail to start with an error regarding the favicon.

Photon version 1.29.2 with the official Docker containers.

Xyphyn commented 6 months ago

As a temporary fix you can set the favicon to /img/logo-background.svg

b2cc commented 6 months ago

fyi This bug still exists for me after applying the recommended fix for PUBLIC_FAVICON on photon:v1.29.3. If I disable PUBLIC_SSR_ENABLED the app works.

Logs (with used ENVs):

Listening on 0.0.0.0:3000
Using the following default settings from the environment:
{
  PUBLIC_FAVICON: "/img/logo-background.svg",
  PUBLIC_SSR_ENABLED: "true",
  PUBLIC_THEME: "system",
  PUBLIC_INSTANCE_URL: "lemmy.example.com",
  PUBLIC_LOCK_TO_INSTANCE: "true",
  PUBLIC_MIGRATE_COOKIE: "false",
  PUBLIC_INTERNAL_INSTANCE: "photon.example.com",
}
32 |    * @param {number} status
33 |    * @param {string} text
34 |    * @param {string} message
35 |    */
36 |   constructor(status, text2, message) {
37 |     super(message);
         ^
error: Not found: /api/v3/site
      at new SvelteKitError (/app/build/server/chunks/index.js:37:5)
      at /app/build/server/index.js:2777:18
      at resolve2 (/app/build/server/index.js:2673:27)
      at resolve (/app/build/server/index.js:2609:43)
      at /app/build/server/index.js:2607:28

32 |    * @param {number} status
33 |    * @param {string} text
34 |    * @param {string} message
35 |    */
36 |   constructor(status, text2, message) {
37 |     super(message);
         ^
error: Not found: /api/v3/post/list
      at new SvelteKitError (/app/build/server/chunks/index.js:37:5)
      at /app/build/server/index.js:2777:18
      at resolve2 (/app/build/server/index.js:2673:27)
      at resolve (/app/build/server/index.js:2609:43)
      at /app/build/server/index.js:2607:28

32 |    * @param {number} status
33 |    * @param {string} text
34 |    * @param {string} message
35 |    */
36 |   constructor(status, text2, message) {
37 |     super(message);
         ^
error: Not found: /favicon.ico
      at new SvelteKitError (/app/build/server/chunks/index.js:37:5)
      at /app/build/server/index.js:2777:18
      at resolve2 (/app/build/server/index.js:2673:27)
      at resolve (/app/build/server/index.js:2609:43)
      at /app/build/server/index.js:2607:28
Xyphyn commented 6 months ago

You have set PUBLIC_INTERNAL_INSTANCE to photon.example.com it seems. INTERNAL_INSTANCE is the URL the server will send API requests to. In this case, you can probably remove this, or if you're in a docker container, set it to the localhost URL that the server needs to access.

b2cc commented 6 months ago

Ok, thanks for the response @Xyphyn !

To shed a little more light on this: I'm running this on kubernetes (Openshift), and at first I also interpreted the variables as you just described, but I ended up getting errors, so I started to play around with them to see if I could get it working somehow.

However, whenever I set PUBLIC_SSR_ENABLED to true, I start to run into problems.

Currently, the container setup looks like this:

NAME                                 CLUSTER-IP      PORT(S)
lemmy-example-com-lemmy     172.31.123.3    8536/TCP
lemmy-example-com-lemmy-ui  172.31.96.103   1234/TCP
lemmy-example-com-photon    172.31.204.131  3000/TCP
lemmy-example-com-pictrs    172.31.122.69   6669/TCP,8080/TCP

DNS is taken care of internally, so when I enter the Photon container I can reach the Lemmy container by calling its service name with the port, e.g.:

wget -S lemmy-example-com-lemmy:8536/api/v3/site
Connecting to lemmy-example-com-lemmy:8536 (172.31.123.3:8536)
  HTTP/1.1 200 OK
  content-length: 10741
  connection: close
  content-type: application/json
  cache-control: public, max-age=60
  vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers
  date: Mon, 27 May 2024 06:30:18 GMT

saving to 'site'
site                 100% |**********************************************************************************************************************************| 10741  0:00:00 ETA
'site' saved

/tmp $ cat site 
{"site_view":{"site":{"id":1,"name":"Lemmy","published":"2024-05-24T17:41:05.581514Z","updated":"2024-05-24T19:37:28.616195Z","icon":"https://lemmy.example.com/pictrs/image/6b872fbf-f1ba-448d-b5f9-aa2b3db1d9c1.png","actor_id":"https://lemmy.example.com/","last_refreshed_at":"2024-05-24T17:41:05.573591Z"...

So I can reach the Lemmy container on lemmy-example-com-lemmy:8536 and it returns correct data when I call the API endpoint.

From my understanding the correct setup therefore should be:

PUBLIC_INSTANCE_URL: "photon.example.com"
PUBLIC_INTERNAL_INSTANCE: "lemmy-example-com-lemmy:8536"
PUBLIC_SSR_ENABLED: "true"

However, this doesn't work for me, I still end up with that weird favicon error and the app doesn't start up correctly. Maybe I misunderstand what PUBLIC_SSR_ENABLED is supposed to do and I don't even need it in this context?