Skip to content

Frontend installation (Nuxt)

The frontend is a Nuxt 4 application using SSR (nuxt build + Node server). It communicates with Laravel via Sanctum cookie authentication.

Step 1 — Install dependencies

bash
cd /path/to/frontend
npm install

pnpm, yarn, or bun also work if you adapt lockfiles.

Step 2 — Environment file

Copy the example file included in the package:

bash
cp .env.example .env

Edit frontend/.env:

ini
# Public URL where users open the Nuxt app (no trailing slash)
FRONTEND_URL=http://localhost:4000

# Laravel API origin (no trailing slash) — must match APP_URL on backend
API_URL=http://localhost:8000
VariablePurpose
FRONTEND_URLUsed in runtimeConfig.public.baseUrl
API_URLAPI requests + Sanctum CSRF/login (runtimeConfig.public.apiUrl)

Production example:

ini
FRONTEND_URL=https://yourdomain.com
API_URL=https://api.yourdomain.com

WARNING

API_URL must be the backend origin only, not /api. The app appends /api/... automatically.

Step 3 — Development server

bash
npm run dev

Default script (package.json):

json
"dev": "nuxt dev -p 4000 --host"

Open http://localhost:4000.

Step 4 — Production build

bash
npm run build

Output is written to .output/.

Run production server locally

bash
npm run start

Uses:

text
HOST=0.0.0.0 PORT=3000 node .output/server/index.mjs

Set PORT and HOST via environment on your host.

Step 5 — Sanctum / auth module

The project uses nuxt-auth-sanctum with cookie mode. Relevant settings in nuxt.config.ts:

SettingValue
Login endpoint/api/auth/signin
Logout/api/auth/logout
User/api/user
CSRF/sanctum/csrf-cookie

After login, admins redirect to /admin; users to /dashboard (see pages/signin.vue).

Route protection: middleware/auth.global.ts guards /admin and /dashboard.

Step 6 — Verify frontend → API

  1. Open browser devtools → Network.
  2. Load the homepage — requests should go to {API_URL}/api/....
  3. Sign in — you should see sanctum/csrf-cookie then api/auth/signin.
  4. Session cookie laravel_session (name may vary) set on API domain.

If requests fail with CORS errors, fix CORS & Sanctum.

Robots & sitemap (Nuxt server routes)

The frontend serves:

  • /robots.txt — from admin SEO settings (proxied/fetched from API)
  • /sitemap.xml — dynamic sitemap

Ensure your production reverse proxy forwards these routes to the Nuxt server.

Next step

Need help? support@xorinlab.com · Website: xorinlab.com