N
Nuxtβ€’8mo ago
Muhammad Mahmoud

Calling an API on my local machine from within a container only works at first load

Hey guys πŸ‘‹ I'm running a Nuxt app inside a Docker container that talks to my local machine Laravel API on localhost:8000. I've added these lines in my docker-compose file to make the container see my localhost.
extra_hosts:
- 'host.docker.internal:host-gateway'
extra_hosts:
- 'host.docker.internal:host-gateway'
.env
NUXT_PUBLIC_BASE_URL="http://host.docker.internal:8000"
NUXT_PUBLIC_BASE_URL="http://host.docker.internal:8000"
Although The initial page load works, the subsequent link clicks fail with a 404 error as the browser send the requests to http://host.docker.internal:8000/api/some-api-endpoint and don't find it. I guess I need some sort of two-way mapping but I don't have a clue where to start looking.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server