
## ⚠️ Updates are now SAFE — your users & data survive
This zip does **NOT** contain `data/` or `.env` anymore.
- Your live database (users, leads, purchases) is untouched when you upload updates.
- Your live `.env` (your Stripe keys) is untouched too.
- First install only: the app auto-creates `.env` from `FIRST-INSTALL-ONLY.env` and creates the database automatically.
Just extract, then RESTART the app in cPanel (Setup Node.js App → Restart). Verify at /api/version — it should say v9.

# MakeLeads — Clean Install (fixes "Index of /")

Follow these in order. The whole thing takes about 10 minutes.
The "Index of /" page you're seeing means **Step 4 (creating the Node.js
App) hasn't been done, or the app's folder doesn't match where the files
are.** These steps fix that for good.

---

## Step 1 — Pick your folder & clear it out

1. cPanel → **File Manager**.
2. Go to the folder your domain serves from — for the main domain this is
   **`public_html`**. (For a subdomain it's the subdomain's folder.)
3. Turn on hidden files: top-right **Settings** → check **"Show Hidden
   Files (dotfiles)"** → Save. (Important — you need to see `.htaccess`
   and `.env`.)
4. Select everything in the folder and **delete it** so you start clean.
   *(If you have a `data/db.json` with real users you want to keep, first
   download it to your computer, then delete. A fresh install makes a new
   one.)*

## Step 2 — Upload & extract the app

1. Still in that folder, click **Upload** and upload
   `makeleads_update.zip`.
2. Back in File Manager, right-click the zip → **Extract** → extract into
   the **current folder**.
3. **Check the result:** you should now see `server.js`, `app.js`,
   `public/`, `admin/`, `server/` sitting **directly** in the folder — NOT
   inside a sub-folder like `makeleads_update/`. If they landed in a
   sub-folder, open it, select all, **Move** them up one level into the
   main folder.
4. Delete the zip file (optional tidy-up).

## Step 3 — Create the `.env` file

1. In the same folder, find `.env.example`. Right-click → **Copy** → name
   the copy exactly **`.env`**.
   *(Or upload the ready-made env file if you have one and rename it to
   `.env`.)*
2. Right-click `.env` → **Edit** and set at least:
   - `JWT_SECRET=` → any long random string (mash the keyboard 40+ chars).
   - For payments, paste your Stripe keys into `STRIPE_SECRET_KEY=` and
     `STRIPE_PUBLISHABLE_KEY=`.
   Save.

## Step 4 — Create the Node.js App  ← THIS is what fixes "Index of /"

1. cPanel → **Setup Node.js App** (sometimes "Node.js Selector").
2. Click **Create Application**.
3. Fill in exactly:
   - **Node.js version:** newest offered (18, 20, or 22 all fine)
   - **Application mode:** Production
   - **Application root:** the folder from Step 1 — e.g. `public_html`
     (type it exactly; this MUST match where `server.js` lives)
   - **Application URL:** your domain
   - **Application startup file:** `app.js`
4. Click **Create**.
   > When you click Create, cPanel automatically writes the correct
   > `.htaccess` into your folder. This is the file that makes the site
   > work instead of showing "Index of /". Do not upload your own
   > `.htaccess` over it — this app package deliberately does not include
   > one anymore.
5. Click **Start App** (or **Restart** if it already started).

## Step 5 — Verify

1. Visit your domain → you should see the MakeLeads homepage.
2. Visit `yourdomain.com/admin` → admin login screen.
   - Email: `admin@makeleads.us`
   - Password: `MakeLeads2024!`
   - **Change this password immediately** in the admin settings.

The database (`data/db.json`) is created automatically on the first visit,
seeded with sample leads.

---

## If it STILL says "Index of /"

Work down this list — one of these is always the cause:

1. **App root mismatch.** In Setup Node.js App, the **Application root**
   must be the exact folder where `server.js` sits. If files are in
   `public_html` but the app root says `public_html/makeleads`, they don't
   match. Fix the root (or move the files) so they agree, then Restart.

2. **Files in a sub-folder.** If Extract created
   `public_html/makeleads_update/server.js`, move everything up so it's
   `public_html/server.js`. Then Restart.

3. **Regenerate `.htaccess`.** Setup Node.js App → pencil/edit on the app →
   **Save** (rewrites `.htaccess`) → **Restart**. If a stale `.htaccess`
   is still there, delete it in File Manager first (needs hidden files
   visible), then Save.

4. **App stopped/crashed.** In Setup Node.js App, if status isn't
   "running," click Restart and open the app's **log** (link on that same
   screen). If it shows an error, send me those log lines.

5. **508 "Resource Limit Reached".** The app crash-looped earlier and
   Namecheap throttled the account for a bit. Wait 20–30 min, then
   Restart.

Nothing here touches your leads data — it's all routing/config.
