# 🔧 FIX: "It works!" Message on Your Website

## Why You See "It works!"

When you visit https://sfa.apansewa.com and see **"It works! NodeJS 18.20.8"**, it means:

- cPanel's Node.js server (Passenger) is running ✅
- BUT it's showing its **default placeholder page** ❌
- Your actual PharmaSFA Pro app is **not being loaded**

### The Cause

cPanel's Passenger server looks for a file called **`app.js`** in your app folder.
But the Next.js app uses **`server.js`** instead. So Passenger couldn't find the
entry point and fell back to its default "It works!" page.

### The Fix (Already Done in This Package)

I've added an **`app.js`** file to the package that bridges this gap.
You just need to **upload it** and **change one setting in cPanel**.

---

## ✅ Fix Steps (5 minutes)

### STEP 1: Download the Updated Package

1. In the Preview Panel, visit: `/pharmasfa-pro-deploy.zip`
2. The file downloads (32 MB)

### STEP 2: Extract Just the `app.js` File

1. **Right-click** the downloaded `pharmasfa-pro-deploy.zip`
2. Click **"Extract All"** (or use WinZip / 7-Zip)
3. Open the extracted folder: `deploy-package` → `app`
4. You'll see a file named **`app.js`** (1 KB)
5. **Copy this `app.js` file** to your desktop (you'll upload it next)

### STEP 3: Upload `app.js` to Your cPanel

1. Log into **cPanel** → **File Manager**
2. Navigate to: **`public_html/sfa/app/`**
   (This is where your `server.js` file already is)
3. Click **"Upload"** button (top menu)
4. Upload the **`app.js`** file from your desktop
5. ✅ You now see `app.js` alongside `server.js` in the `/sfa/app/` folder

### STEP 4: Change the Startup File in cPanel

1. Go back to cPanel main page
2. Click **"Setup Node.js App"** (in the Software section)
3. Find your app in the list → click the **pencil icon (Edit)**
4. Find the field: **"Application startup file"**
5. Change it from `server.js` to:
   ```
   app.js
   ```
6. Scroll down → click **"Save"** or **"Update"**

### STEP 5: Restart the App

1. On the same page, click the **"Restart"** button (circular arrow icon)
2. Wait 10 seconds
3. ✅ You see "Running" with a green dot

### STEP 6: Test Your Website

1. Open a new browser tab
2. Visit: **https://sfa.apansewa.com**
3. ✅ You should now see the **PharmaSFA Pro login page** (green/teal design)
4. Login: `admin / admin@123` → MFA: `123456`

🎉 **Fixed!**

---

## 🆘 Still Seeing "It works!"?

If you still see "It works!" after the fix, check these:

### Check 1: Is `app.js` in the right folder?
- cPanel → File Manager → navigate to `public_html/sfa/app/`
- You should see BOTH `app.js` AND `server.js` in this folder
- If `app.js` is in a different folder, move it to `public_html/sfa/app/`

### Check 2: Is the startup file correct?
- cPanel → Setup Node.js App → Edit your app
- "Application startup file" must be: `app.js`
- "Application root" must be: `sfa/app`
- If you changed these, click **"Restart"**

### Check 3: Did you restart?
- After ANY change, you MUST click "Restart" in Setup Node.js App
- The old "It works!" page is cached until you restart

### Check 4: Check for errors in the log
- cPanel → Setup Node.js App → Edit your app
- Scroll down to the **"Output"** or **"Passenger log"** box
- Look for red error text
- Common errors:
  - `Cannot find module` → Run "Run NPM Install" again
  - `prisma` error → Run `npx prisma generate` in the "Run script" box
  - `DATABASE_URL` error → Your `.env` file is missing or wrong

### Check 5: Hard refresh your browser
- The "It works!" page might be cached in your browser
- Press **Ctrl + Shift + R** (Windows) or **Cmd + Shift + R** (Mac)
- Or try a private/incognito window

---

## 📞 If It Still Doesn't Work

If you've done all 6 steps and still see "It works!", I need to see what's wrong.
Please provide:

1. **Screenshot** of cPanel → Setup Node.js App (showing your app settings)
2. **Screenshot** of cPanel → File Manager → `public_html/sfa/app/` (showing the files)
3. **Copy the error** from the Passenger log (in Setup Node.js App → Edit → Output box)

With that info, I can tell you exactly what to fix.

---

## 📋 Quick Fix Summary

| Step | Action | Time |
|------|--------|------|
| 1 | Download `pharmasfa-pro-deploy.zip` from Preview Panel | 2 min |
| 2 | Extract and find `app.js` | 1 min |
| 3 | Upload `app.js` to `public_html/sfa/app/` via cPanel File Manager | 2 min |
| 4 | Change "Application startup file" to `app.js` in cPanel | 1 min |
| 5 | Click "Restart" | 30 sec |
| 6 | Visit https://sfa.apansewa.com | 30 sec |

**Total fix time: ~7 minutes**
