App Cities
Your app, online
Networking

How to connect a frontend to its backend after deployment

Avoid localhost and CORS mistakes by separating browser URLs from private Docker service addresses.

App Cities · 2 min · Updated

Your frontend shows the page. Your backend does the work behind it. They need to talk to each other. A request from the browser needs a public URL. A request inside the pod can use a private Docker service name. These two addresses are not always the same.

The steps

  1. Find where each API request runs. Browser-side JavaScript and server-rendered requests may need different base URLs.
  2. Keep internal addresses for server-to-server calls. A Docker name such as api is useful inside Compose but is not a public hostname.
  3. For browser requests, route the API through the public web entry, often under /api. Configure that routing in your project's web service rather than assuming every container gets its own public URL.
  4. Check the browser network panel and backend logs together. Verify scheme, path, authentication cookies and allowed origins.

A common question

Does every service get a public address?

No. The project identifies its public web service. Internal APIs and databases can remain private behind that entry point.

Ready to try your project?

Prepare your project, check the prices and choose how you want to deploy.

Keep learning