OktopUSP/oktopus

frontend always calls localhost

ArthurGing opened this issue · 4 comments

Even though NEXT_PUBLIC_REST_ENDPOINT and NEXT_PUBLIC_WS_ENDPOINT are set, the frontend still calls localhost.
My browser is Firefox

Screenshot from 2024-06-03 10-56-30

Have yout tried to delete the container and create it again?

@ArthurGing
In the file ~/oktopus/deploy/compose/.env.frontend try changing to another IP other than the loopback IP of the running machine. I changed it and it worked for me

I tested with Ubuntu 24.04 LTS virtual machine over QEMU and Docker installed. Here, I had to modify the NEXT_PUBLIC_REST_ENDPOINT and NEXT_PUBLIC_WS_ENDPOINT variables in the ~/oktopus/deploy/compose/.env.frontend file to the LAN IP that QEMU's DHCP handed over to the VM.

Ubuntu VM

ubuntu@docker:~/oktopus/deploy/compose$ batcat .env.frontend 
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: .env.frontend
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ # ----------------------------- Local Environment ---------------------------- #
   2   │ 
   3 ~#NEXT_PUBLIC_REST_ENDPOINT="http://localhost:8000/api"
   4 ~#NEXT_PUBLIC_WS_ENDPOINT="http://localhost:5000/"
   5 ~ │ NEXT_PUBLIC_REST_ENDPOINT="http://10.22.100.143:8000/api"
   6 ~ │ NEXT_PUBLIC_WS_ENDPOINT="http://10.22.100.143:5000/"
   7   │ # ---------------------------------------------------------------------------- #
   8   │ 
   9   │ # -------------------------- Production Environment -------------------------- #
  10   │ 
  11   │ #NEXT_PUBLIC_REST_ENPOINT="https://demo.oktopus.app.br/api"
  12   │ #NEXT_PUBLIC_WS_ENPOINT="https://demo.oktopus.app.br/"
  13   │ # ---------------------------------------------------------------------------- #
  14   │ 
  15   │ # ---------------------------- Mocked Environment ---------------------------- #
  16   │ 
  17   │ #NEXT_PUBLIC_REST_ENPOINT="https://d9962fd9-2464-4a30-9a86-a15a04b57ad0.mock.pstmn.io"
  18   │ 
  19   │ # ---------------------------------------------------------------------------- #

# IP addr
ubuntu@docker:~/oktopus/deploy/compose$ ip -br -4 addr show dev ens3
ens3             UP             10.22.100.143/24 metric 100

# Ubuntu 24.04
ubuntu@docker:~/oktopus/deploy/compose$ lsb_release -d
No LSB modules are available.
Description:	Ubuntu 24.04 LTS

# Docker 26.1.4
ubuntu@docker:~/oktopus/deploy/compose$ docker --version
Docker version 26.1.4, build 5650f9b

ubuntu@docker:~/oktopus/deploy/compose$ docker container ps
CONTAINER ID   IMAGE                           COMMAND                  CREATED          STATUS          PORTS                                                                                            NAMES
7a0fb8412123   oktopusp/obuspa:latest          "obuspa -r /obuspa/o…"   40 minutes ago   Up 40 minutes                                                                                                    obuspa-websockets
e92755ab4125   oktopusp/obuspa:latest          "obuspa -r /obuspa/o…"   40 minutes ago   Up 40 minutes                                                                                                    obuspa-mqtt
8db27609bcb6   oktopusp/controller             "/controller"            47 minutes ago   Up 46 minutes   0.0.0.0:8000->8000/tcp, :::8000->8000/tcp                                                        controlller
ed04a0c20e0e   oktopusp/ws-adapter             "/ws-adapter"            47 minutes ago   Up 46 minutes                                                                                                    ws-adapter
b802eefe3e0d   oktopusp/adapter                "/adapter"               47 minutes ago   Up 46 minutes                                                                                                    adapter
083db31f6134   oktopusp/stomp-adapter          "/stomp-adapter"         47 minutes ago   Up 46 minutes                                                                                                    stomp-adapter
ed776ea73cd3   oktopusp/mqtt-adapter           "/mqtt-adapter"          47 minutes ago   Up 46 minutes                                                                                                    mqtt-adapter
213fc71c1b56   nats:latest                     "/nats-server -n okt…"   47 minutes ago   Up 46 minutes   0.0.0.0:4222->4222/tcp, :::4222->4222/tcp, 0.0.0.0:8222->8222/tcp, :::8222->8222/tcp, 6222/tcp   nats
91661727cd81   oktopusp/frontend               "/app/entrypoint.sh …"   47 minutes ago   Up 46 minutes   0.0.0.0:3000->3000/tcp, :::3000->3000/tcp                                                        frontend
b6b631c0bb4d   portainer/portainer-ce:latest   "/portainer"             47 minutes ago   Up 46 minutes   8000/tcp, 9000/tcp, 0.0.0.0:9443->9443/tcp, :::9443->9443/tcp                                    portainer
05e429509a53   mongo                           "docker-entrypoint.s…"   47 minutes ago   Up 47 minutes   0.0.0.0:27017->27017/tcp, :::27017->27017/tcp                                                    mongo_usp
27f776a7565c   oktopusp/ws                     "/ws"                    47 minutes ago   Up 46 minutes   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp                                                        websockets
986aa619f8bc   oktopusp/socketio               "docker-entrypoint.s…"   47 minutes ago   Up 47 minutes   0.0.0.0:5000->5000/tcp, :::5000->5000/tcp                                                        socketio
71ddab54225b   oktopusp/acs                    "/acs"                   47 minutes ago   Up 46 minutes   0.0.0.0:9292->9292/tcp, :::9292->9292/tcp                                                        acs
d95335e2a34d   oktopusp/mqtt                   "/mqtt"                  47 minutes ago   Up 46 minutes   0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 0.0.0.0:8883->8883/tcp, :::8883->8883/tcp             mqtt
36e585da6cee   oktopusp/stomp                  "/stomp"                 47 minutes ago   Up 46 minutes   0.0.0.0:61613->61613/tcp, :::61613->61613/tcp 

Accessing from the host machine with Fedora 40 and Firefox 126.0
env frontend

Have yout tried to delete the container and create it again?

@ArthurGing In the file ~/oktopus/deploy/compose/.env.frontend try changing to another IP other than the loopback IP of the running machine. I changed it and it worked for me

I tested with Ubuntu 24.04 LTS virtual machine over QEMU and Docker installed. Here, I had to modify the NEXT_PUBLIC_REST_ENDPOINT and NEXT_PUBLIC_WS_ENDPOINT variables in the ~/oktopus/deploy/compose/.env.frontend file to the LAN IP that QEMU's DHCP handed over to the VM.

Ubuntu VM

ubuntu@docker:~/oktopus/deploy/compose$ batcat .env.frontend 
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: .env.frontend
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ # ----------------------------- Local Environment ---------------------------- #
   2   │ 
   3 ~#NEXT_PUBLIC_REST_ENDPOINT="http://localhost:8000/api"
   4 ~#NEXT_PUBLIC_WS_ENDPOINT="http://localhost:5000/"
   5 ~ │ NEXT_PUBLIC_REST_ENDPOINT="http://10.22.100.143:8000/api"
   6 ~ │ NEXT_PUBLIC_WS_ENDPOINT="http://10.22.100.143:5000/"
   7   │ # ---------------------------------------------------------------------------- #
   8   │ 
   9   │ # -------------------------- Production Environment -------------------------- #
  10   │ 
  11   │ #NEXT_PUBLIC_REST_ENPOINT="https://demo.oktopus.app.br/api"
  12   │ #NEXT_PUBLIC_WS_ENPOINT="https://demo.oktopus.app.br/"
  13   │ # ---------------------------------------------------------------------------- #
  14   │ 
  15   │ # ---------------------------- Mocked Environment ---------------------------- #
  16   │ 
  17   │ #NEXT_PUBLIC_REST_ENPOINT="https://d9962fd9-2464-4a30-9a86-a15a04b57ad0.mock.pstmn.io"
  18   │ 
  19   │ # ---------------------------------------------------------------------------- #

# IP addr
ubuntu@docker:~/oktopus/deploy/compose$ ip -br -4 addr show dev ens3
ens3             UP             10.22.100.143/24 metric 100

# Ubuntu 24.04
ubuntu@docker:~/oktopus/deploy/compose$ lsb_release -d
No LSB modules are available.
Description:	Ubuntu 24.04 LTS

# Docker 26.1.4
ubuntu@docker:~/oktopus/deploy/compose$ docker --version
Docker version 26.1.4, build 5650f9b

ubuntu@docker:~/oktopus/deploy/compose$ docker container ps
CONTAINER ID   IMAGE                           COMMAND                  CREATED          STATUS          PORTS                                                                                            NAMES
7a0fb8412123   oktopusp/obuspa:latest          "obuspa -r /obuspa/o…"   40 minutes ago   Up 40 minutes                                                                                                    obuspa-websockets
e92755ab4125   oktopusp/obuspa:latest          "obuspa -r /obuspa/o…"   40 minutes ago   Up 40 minutes                                                                                                    obuspa-mqtt
8db27609bcb6   oktopusp/controller             "/controller"            47 minutes ago   Up 46 minutes   0.0.0.0:8000->8000/tcp, :::8000->8000/tcp                                                        controlller
ed04a0c20e0e   oktopusp/ws-adapter             "/ws-adapter"            47 minutes ago   Up 46 minutes                                                                                                    ws-adapter
b802eefe3e0d   oktopusp/adapter                "/adapter"               47 minutes ago   Up 46 minutes                                                                                                    adapter
083db31f6134   oktopusp/stomp-adapter          "/stomp-adapter"         47 minutes ago   Up 46 minutes                                                                                                    stomp-adapter
ed776ea73cd3   oktopusp/mqtt-adapter           "/mqtt-adapter"          47 minutes ago   Up 46 minutes                                                                                                    mqtt-adapter
213fc71c1b56   nats:latest                     "/nats-server -n okt…"   47 minutes ago   Up 46 minutes   0.0.0.0:4222->4222/tcp, :::4222->4222/tcp, 0.0.0.0:8222->8222/tcp, :::8222->8222/tcp, 6222/tcp   nats
91661727cd81   oktopusp/frontend               "/app/entrypoint.sh …"   47 minutes ago   Up 46 minutes   0.0.0.0:3000->3000/tcp, :::3000->3000/tcp                                                        frontend
b6b631c0bb4d   portainer/portainer-ce:latest   "/portainer"             47 minutes ago   Up 46 minutes   8000/tcp, 9000/tcp, 0.0.0.0:9443->9443/tcp, :::9443->9443/tcp                                    portainer
05e429509a53   mongo                           "docker-entrypoint.s…"   47 minutes ago   Up 47 minutes   0.0.0.0:27017->27017/tcp, :::27017->27017/tcp                                                    mongo_usp
27f776a7565c   oktopusp/ws                     "/ws"                    47 minutes ago   Up 46 minutes   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp                                                        websockets
986aa619f8bc   oktopusp/socketio               "docker-entrypoint.s…"   47 minutes ago   Up 47 minutes   0.0.0.0:5000->5000/tcp, :::5000->5000/tcp                                                        socketio
71ddab54225b   oktopusp/acs                    "/acs"                   47 minutes ago   Up 46 minutes   0.0.0.0:9292->9292/tcp, :::9292->9292/tcp                                                        acs
d95335e2a34d   oktopusp/mqtt                   "/mqtt"                  47 minutes ago   Up 46 minutes   0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 0.0.0.0:8883->8883/tcp, :::8883->8883/tcp             mqtt
36e585da6cee   oktopusp/stomp                  "/stomp"                 47 minutes ago   Up 46 minutes   0.0.0.0:61613->61613/tcp, :::61613->61613/tcp 

Accessing from the host machine with Fedora 40 and Firefox 126.0 env frontend

Even though NEXT_PUBLIC_REST_ENDPOINT and NEXT_PUBLIC_WS_ENDPOINT are set, the frontend still calls localhost on the path "/socket.io". This issue only occurs with "/socket.io"; other APIs are calling the correct endpoint. My VM is Ubuntu 22.04 and the host browser is Firefox 126.0.1. The issue doesn't happen if I switch to Chrome.

Can it be something related to Firefox cache?