# Zeour Website (Next.js wrapper around static site)

This app serves the existing static site via Next.js, preserving `public/` HTML/CSS/JS while adding clean routes and API proxy rewrites to the proxy service. It does not run a custom `server.js`; use the Next.js dev server.

## What’s included
- Static site under `public/` (HTML, CSS, JS, images, blogs)
- Route rewrites (e.g. `/features` → `/features.html`)
- API rewrites to the proxy (see below)
- Minimal Next.js setup with `dev`, `build`, `start` scripts

## Run locally
1. `npm install`
2. `npm run dev`
3. Open http://YOUR_HOST_IP:4003 (binds on 0.0.0.0)

## Build & serve
- `npm run build`
- `npm start`

## API proxy rewrites
Defined in `next.config.mjs`:
- `GET/POST /api/:path*` → `http://127.0.0.1:4002/api/:path*`
- `POST /init` → `http://127.0.0.1:4002/init`
- Clean routes for HTML pages (e.g., `/features` → `/features.html`)

Notes:
- Do not create Next.js API routes under `pages/api` for backend endpoints (e.g., quiz/training/newsletter). They will shadow rewrites and prevent requests from reaching the proxy.

## Integration with the proxy
- The site calls the proxy for all APIs.
- An initial `POST /init` issues a `proxy_digest` cookie required by some protected endpoints.
- Stripe checkout flow:
  - UI posts `/api/subscription/checkout` to the proxy.
  - On `receipt.html`, the site fetches `GET /api/subscription/receipt` to show details.
  - For local/dev (no webhook), the site calls `POST /api/subscription/finalize { session_id }` once to persist the order in Laravel.
 - Quiz and Training are forwarded to the proxy and then to Laravel. The proxy CCs the recipient configured in its `.env` (if set) so admins receive the full answers.

## Email validation UX
- The checkout form validates email with a stricter regex and shows a toast near the input if invalid (e.g., accidental commas in the domain).
- The proxy also validates email server‑side and returns `400 { error: "Invalid email address." }` if malformed.

## Orchestrator (optional)
- From repo root, `scripts/zeourctl.sh` can start/stop/status/health services.
  - Start all: `scripts/zeourctl.sh start all`
  - Health: `scripts/zeourctl.sh health`
  - Logs: `.orchestrator/logs/frontend.log`

## Notes
- The site currently uses Tailwind CDN, Alpine, and Font Awesome in HTML files for parity.
- You can progressively convert pages to React components later without changing the UI.
