How to make a call from frontend to backend container using the DNS?

I created this docker-compose for my application:

version: "3.9"
services:
  db:
    image: postgres:15-alpine
    container_name: db
    expose:
      - 5432
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    volumes: 
      - db:/var/lib/postgresql/data
    restart: 'always'
    networks:
      - backend_network
  user:
    container_name: user-management
    build:
      context: ./user-management
      dockerfile: Dockerfile-dev
    ports:
      - "5000:5000"
    expose:
      - 5000
    depends_on:
      - db
    env_file:
      - ./user-management/.env.dev
    volumes:
      - /tmp/user-management/npm-cache:/root/.npm:z
      - ./user-management/src:/usr/src/user-management/src
    networks:
      -  frontend_network
      -  backend_network
    restart: 'no'


  frontend:
    container_name: frontend
    build:
      context: ./frontend
      dockerfile: Dockerfile-dev
    environment:
      - NEXT_PUBLIC_USER_MANAGEMENT_URL=${NEXT_PUBLIC_USER_MANAGEMENT_URL}
    ports:
      - "3000:3000"
    networks:
      - frontend_network
    depends_on:
      - user
      - quiz
    restart: 'no'
    volumes:
      - ./frontend/public:/usr/src/frontend/public
      - ./frontend/src:/usr/src/frontend/src
    
  
volumes:
  db:
    driver: local

networks:
  frontend_network:
  backend_network:
    driver: bridge

in the .env file I set NEXT_PUBLIC_USER_MANAGEMENT_URL=http://user:5000 but the call from the frontend does not work.
The call is successfull only if I change it to localhost:5000.
What’s wrong with my config to use make a call form frontend to backed using docker dns?

You have to use the host name from the perspective where the fronted process that actually communicates with the backend is executed.

Does the frontend container just serve content, and the relevant process is actually running as JavaScript in the browser on the host and directly communicates with the backend? If this is the case, then you need to use whatever url is required to access the published port of the backend.