umbertoghio / self-hosted-expo-updates-server

MIT License
136 stars 17 forks source link

API_BASE_URL not changing #18

Closed lukasa1993 closed 3 months ago

lukasa1993 commented 4 months ago

trying to use docker production version and web API_BASE_URL doesn't change url in network logs it still localhost:3000

umbertoghio commented 4 months ago

Hello, the API_BASE_URL is used by the web frontend to know where to connect to, the server always listens to localhost:3000

lukasa1993 commented 4 months ago

yea i am referring to front end it always goes to localhost:3000 it ignores API_BASE_URL env variable

umbertoghio commented 4 months ago

Are you running it from inside docker? the mechanism for the connection relies to the status script that runs the loadEnv, creating an env-config.js that is provided to the browser. can you check the content of this file? yourwebinstance/env-config.js is it set properly?

lukasa1993 commented 4 months ago

this is how i run it

expo_update_web:
    image: ghcr.io/umbertoghio/self-hosted-expo-updates-server-web:latest
    user: root
    container_name: expo_update_web
    restart: always
    volumes:
      - ./expo/web:/expo
    environment:
      - API_BASE_URL=https://expo.example.com
      - ENVIRONMENT=production
    networks:
      - lnh
    command: /expo/start.sh

i don't see env-config.js file inside docker container at least not at root level

umbertoghio commented 4 months ago

Probably this part is missing from your start.sh

image

the loadEnv script generates the env-config.js , then places it in the root folder to be picked up by the browser

lukasa1993 commented 4 months ago

oh if i cat /usr/share/nginx/html/env-config.js

it has this

window._env_ = { API_BASE_URL: 'http://localhostu:3000', ENVIRONMENT: 'development' }
EliotAmn commented 3 months ago

Simple question, why we are constrained to use an Nginx variable ? Why not simply pass the api url with the web server of the frontend? I use NginxProxyManager, and it's not verry easy to setup. Thank you also for this verry useful tool :)

umbertoghio commented 3 months ago

Hello, @lukasa1993 sorry, I missed your last message, have you managed to solve it?

@EliotAmn It is not an nginx variable, the variable is set in the env of the docker running the web server, on startup this url is picked up and set inside a .JS file that is sent to the user's browser. So this is how the JS running in the browser knows where to connect to.

Feel free to fork the project and hardcode your URL in the JS client.

Hope that helps

lukasa1993 commented 3 months ago

Hello,

@lukasa1993 sorry, I missed your last message, have you managed to solve it?

@EliotAmn

It is not an nginx variable, the variable is set in the env of the docker running the web server, on startup this url is picked up and set inside a .JS file that is sent to the user's browser.

So this is how the JS running in the browser knows where to connect to.

Feel free to fork the project and hardcode your URL in the JS client.

Hope that helps

not with config i edited container manually but with config i couldn't solve it

EliotAmn commented 3 months ago

This is an extract of my production docker-compose.yml

self_hosted_expo_updates_server_web:
    image: ghcr.io/umbertoghio/self-hosted-expo-updates-server-web:latest
    container_name: self_hosted_expo_updates_server_web
    restart: always
    depends_on:
      - self_hosted_expo_updates_server_api
    ports:
      - 4748:8080 # Put this behind an https reverse proxy if you want to use it in production
    environment:
      - API_BASE_URL=https://to-api.my-private-domain.fr # URL of the API server

But :

image

Yes i can edit js files directly, but i want to sometime pull the repo, and it can cause conflicts issues.

umbertoghio commented 3 months ago

Let me investigate it, seems that there's something wrong with the image

umbertoghio commented 3 months ago

The last PR had a switch to rootless nginx, good idea but I forgot to check the loadEnv script, I've committed a fix and a new docker image is available without this problem. Have a nice day!

EliotAmn commented 3 months ago

I'm sorry but I have pull your new images, and the problem still here... The web console try again to connect to ws://localhost:3000. I have re-clone the repo, and repull all images. When I try to use it in development mode, I got this error on start: image

and the web interface like that : image

I have an other error, but I think it's another issue : image

umbertoghio commented 3 months ago

Strange issue, I just started from master and development docker-compose started just fine, the issue I fixed was in the production environment.

you may investigate the startup-dev script, this is what I have:

image

umbertoghio commented 3 months ago

Oh, I see, case sensitivity issue on Deploy / deploy, committed the fix

EliotAmn commented 3 months ago

Ok it's good for the env issue. Thank you very much ! But the server-side error still here : Good luck haha :)

{
   "level":50,
   "time":1722606778617,
   "pid":1,
   "hostname":"269b883a4368",
   "msg":"TypeError: Cannot read properties of undefined (reading 'find')\n    at Object._find (/home/node/server/node_modules/feathers-mongodb/lib/index.js:123:26)\n    at callMethod (/home/node/server/node_modules/@feathersjs/adapter-commons/lib/service.js:13:22)\n    at Object.find (/home/node/server/node_modules/@feathersjs/adapter-commons/lib/service.js:63:16)\n    at /home/node/server/node_modules/@feathersjs/feathers/lib/hooks/index.js:57:33\n    at new Promise (<anonymous>)\n    at /home/node/server/node_modules/@feathersjs/feathers/lib/hooks/index.js:54:27\n    at async Object.find (/home/node/server/src/services/status.js:17:22)"
}
umbertoghio commented 3 months ago

that seems just a missing record from the db, you may ignore it