Nextjs Docker container Fetch Failed #68564
Replies: 2 comments 4 replies
-
Fixed it. Closing. |
Beta Was this translation helpful? Give feedback.
4 replies
-
In client components, you should use http://localhost:8080, but in server components, you need to use http://be:8080. This is because, on the server side, the connection is made between services within the Docker network, where be refers to the backend service. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hi. I'm using an issue where when I build my next app with docker compose to run it alongside my backend my api fetches fail.
I know the connection to the backend is good. I'm also connected to a websocket on the same backend and it works just fine.
Everything works when I do
npm run build
and donpm start
in terminal with just the backend running in the container.I want to call http://localhost:8080/games and http://localhost:8080/leaderboard. However, I get the following error:
I think the following are all the relevant files:
api.ts
The baseURL is definitely http://localhost:8080. I logged it out.
app/leaderboard/page.tsx
app/games/page.tsx
docker-compose.yml
Dockerfile... I've also tried the Vercel provided Dockerfile from here and the only difference is the error changes slightly.
Error with Vercel Dockerfile:
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions