---
topic: two-apps
connector: "deploy_app, once per app"
api: "POST https://ship.embarko.ai/apps, once per app"
requires: [deploy]
---

[← Guide home](https://embarko.ai/docs)

# Frontend and backend

**On this page:** Steps, A private app with a public one, Limits, What to tell the person

> Plain words unless the person is a developer. Never invent a link, name or code. [Rules](https://embarko.ai/docs/prerequisites) Needs first: [deploy](https://embarko.ai/docs/deploy).

A frontend and a backend are two apps with two addresses. Deploy the backend first, then point the frontend at its address.

**Connector:** deploy_app, once per app

**Done when:** A feature on the frontend that calls the backend works at the frontend's link. For a private and a public app: the private app shows the public app's data, and its internal routes answer 401 without the key.

**Steps**

1. Package each part from its own folder (the one with its manifest), never the repo root. Give them related names, such as acme-api and acme-web.
2. Deploy the backend first. Wait until it is live; its address is https://acme-api.embarko.app.
3. In the frontend, set the backend address in the code or a committed config file (for example src/config.js). .env files are left out of the upload, so a VITE_ value in .env.production will not reach the build.
4. In the backend, allow the frontend's address in CORS: https://acme-web.embarko.app (and a custom domain if you add one later).
5. Deploy the frontend, then open it and use a feature that calls the backend.
6. Secrets (API keys) go on the backend as env vars; over HTTP that needs the backend claimed first (see claim).

**A private app with a public one**

1. Use this when one part is for the team and the other is for everyone: a staff admin page next to a customer site, or a webhook receiver (Stripe, a form service) next to a locked tool. A locked app blocks every call that is not a signed-in member, so the public part cannot live inside it.
2. Keep the data in ONE app, the public one (it holds the customers' sign-ups and orders under DATA_DIR). The locked app owns no copy.
3. Make a long random key and set it as an env var on both apps, for example INTERNAL_KEY (see env-vars). Never put it in code or embarko.json.
4. In the public app, add the routes the locked app needs under one prefix (for example /internal/orders). Each refuses with 401 unless the request has the header X-Internal-Key equal to INTERNAL_KEY. Do not allow them in CORS.
5. The locked app calls those routes from its server, never from the browser, with the header. It may call the public app; the public app can never call the locked one.
6. Lock only the private app ("lock": true in its embarko.json). Read who signed in there (see lock); the public app keeps its own sign-up for customers.

**Limits**

- Two apps count as two apps on the person's plan.
- The apps cannot share files: only HTTP between them.
- A locked app can call other apps; nothing can call a locked app except the browser of someone who signed in to it (a member, or anyone with its password).

**What to tell the person**

- done: "Your app is live: https://acme-web.embarko.app."

**Next:** Deploy the backend, then the frontend.

**Related:** [env-vars](https://embarko.ai/docs/env-vars) · [custom-domain](https://embarko.ai/docs/custom-domain) · [lock](https://embarko.ai/docs/lock)

---

[Guide home](https://embarko.ai/docs) · JSON: add .json