replace hard coded ip address with something else in docker compose on linux

I’m using linux and trying to set up a docker compose app on raspberry pi. Below is my compose.yaml file. How do I configure this so that I don’t have to hard code the ip address in the yaml file?

    services:
        client:
            build: client/.
            ports:
                - "5173:5173"
            networks:
                - backend
            environment:
                - VITE_HOST=192.168.0.147 ## <-- bad!
            extra_hosts:
                - "host.docker.internal:host-gateway"
        server:
            build: express/.
            ports:
                - "8008:8008"
            networks:
                - backend
            extra_hosts:
                - "host.docker.internal:host-gateway"
            environment:
                - HOST=locaalhost
                - HOST_IP=host.docker.internal
            volumes:
                - /home:/home

    volumes:
        home:

    networks:
        backend:

Below is a code snippet that shows how the VITE_HOST env line is used in the client. It is used to connect to the ‘server’. The client is a vite/vue project. The server saves info from the client to the underlying operating system.

    const host =  import.meta.env.VITE_HOST;
    const url = `http://${host}:8008/users`;

    const response = await fetch(url , {
                method: "GET",
                headers: {
                    "Access-Control-Allow-Origin": "*",
                    "Access-Control-Allow-Methods": "GET, OPTIONS, PUT, POST",
                    "Access-Control-Allow-Headers": "X-Requested-With",
                    "Content-Type": "text/plain"
                }
            });
    ...

For some reason host.docker.internal doesn’t do anything on my pi or my desktop (my desktop is linux). How can I make this work?? Thanks.