Two apps, one server: api.acme.app (Laravel) and acme.app (Next.js or Nuxt in SSR mode). Both deploy from Git with zero downtime; the Node app restarts blue/green.
- acme.appNode app, SSR, blue/green restarts
- api.acme.appLaravel app, FPM or Octane
- Serverone Cipi install
Key ideas, in plain words#
| Term | Meaning |
|---|---|
| API | The Laravel app answers JSON, no HTML |
| SSR | Server-side rendering: Next.js or Nuxt runs as a Node process that builds HTML per request |
| Sanctum | Laravel's auth for SPAs (cookies) and mobile apps (tokens) |
| CORS | Browser rules for calling an API on another domain |
1. The API#
sudo cipi app create --user=api --domain=api.acme.app \
--repository=git@github.com:acme/api.git --php=8.6
sudo cipi deploy api && sudo cipi ssl install apiFor cookie-based auth from the front end, configure Sanctum: SANCTUM_STATEFUL_DOMAINS=acme.app, SESSION_DOMAIN=.acme.app, and CORS for https://acme.app:
sudo cipi app env api --set=SANCTUM_STATEFUL_DOMAINS=acme.app sudo cipi app env api --set=SESSION_DOMAIN=.acme.app
2. The front end#
sudo cipi app create --user=web --domain=acme.app \
--repository=git@github.com:acme/web.git --node=ssr --framework=next --node-version=24
sudo cipi deploy web && sudo cipi ssl install webUse --framework=nuxt for Nuxt. Each deploy installs from your lockfile, builds, starts the new process, checks the health path and only then switches traffic.
| Mode | For |
|---|---|
ssr | Next.js, Nuxt, SvelteKit, Remix, Astro SSR |
static | Pre-rendered sites (Astro, nuxt generate) |
spa | Vite single-page apps |
3. Point the front end at the API#
Build-time variables go in the Node app's shared/.env, read at build:
sudo cipi app env web --set=NEXT_PUBLIC_API_URL=https://api.acme.app sudo cipi deploy web
4. Keep both in their repositories#
Each repository can carry its own cipi.yml: workers, schedule and health for the API, node: settings for the front end. Examples in cipi.yml recipes.
Troubleshooting#
| Problem | Fix |
|---|---|
| CORS error in the browser | Add the front end's origin in config/cors.php, supports_credentials true for cookies |
| 419 CSRF on login | Call /sanctum/csrf-cookie first; check SANCTUM_STATEFUL_DOMAINS and SESSION_DOMAIN |
| 401 after login | Cookie on the wrong domain: SESSION_DOMAIN=.acme.app |
| Front end calls the old API URL | NEXT_PUBLIC_* is baked at build: redeploy the front end |
Questions
Same domain or subdomains?
Subdomains (api.acme.app and acme.app) are simplest. Sanctum's cookie auth needs both on the same parent domain.
Can the front end be static instead?
Yes: --node=static --output=dist serves a built SPA from Nginx with no Node process.
Does the Node app get zero-downtime deploys too?
Yes. A new release is built and started, checked, then traffic switches.
What if a step fails?
Read the troubleshooting table above first. Then check the matching docs page, open a GitHub issue, or ask in the community. Most commands print the fix when they refuse something.
Do I need the web panel for this?
No. Every step works from the CLI. The optional web panel shows the same things in a browser.
Can I run these commands from my laptop?
Many of them, through cipi-cli and the API, with a scoped token. Otherwise ssh cipi@your-server and use sudo cipi ….
Will this affect other apps on the server?
No, unless the step says it's server-wide (installing a PHP version, firewall, Cloudflare tunnel). Each app has its own user, PHP pool, database and Valkey.