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
- Traefik receives the HTTPS request and passes it to the web container, based on the domain name. See Traefik.
- Next.js runs
app/page.json the server. Because the page is markeddynamic = 'force-dynamic', this happens on every request: products are always up to date. page.jscallsfetchProducts()fromlib/products.js, which readsAPI_URLand callsGET {API_URL}/api/products/.- The API reads the database and returns a array.
- 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.