Skip to content

The path of a request ​

What happens between the moment an employee opens https://trinity.jostud.com and the moment they see the product list?

Step by step ​

  1. Traefik receives the HTTPS request and passes it to the web container, based on the domain name. See Traefik.
  2. Next.js runs app/page.js on the server. Because the page is marked dynamic = 'force-dynamic', this happens on every request: products are always up to date.
  3. page.js calls fetchProducts() from lib/products.js, which reads API_URL and calls GET {API_URL}/api/products/.
  4. The API reads the database and returns a array.
  5. Next.js turns the components into HTML and sends it. The browser shows the page without ever talking to the API.

And when you add a product? ​

The code details are in Adding and deleting.

If the API does not answer

fetchProducts() throws an error, page.js catches it and shows "API indisponible : …" (API unavailable) instead of crashing. The web container stays healthy: its /api/health does not depend on the API.