# FINAL BUILD - Follow This Exactly

The build is still using localhost:8000. Follow these exact steps.

---

## Step 1: Clean Everything

Open Command Prompt in your project:

```cmd
cd C:\Users\khawa\Herd\Aria-Herat-Mohandes-Zada-Construction\frontend

rmdir /s /q dist
rmdir /s /q .quasar
rmdir /s /q node_modules\.vite
```

---

## Step 2: Verify Environment Files

Check these files exist:

**frontend/.env**
```
VITE_API_URL=https://herataria.nova.af/backend/public
```

**frontend/.env.production**
```
VITE_API_URL=https://herataria.nova.af/backend/public
```

Both files should have the EXACT same content (already done by me ✅)

---

## Step 3: Build with Explicit Mode

Run this command:

```cmd
npm run build -- --mode production
```

OR just:

```cmd
npm run build
```

**IMPORTANT:** Watch the output! It should show:
```
App • Env • Client code prefix: QCLI_; no dotenv files
```

---

## Step 4: Verify the Build

After build completes, run this command:

```cmd
cd dist\spa\assets
findstr /S "localhost:8000" *.js
```

**Expected Result:** NO OUTPUT (no "localhost:8000" found)

**If you see localhost:8000:** The build didn't use the .env file!

---

## Step 5: Manual Check

Open any `.js` file in `dist\spa\assets\` with Notepad.

Search for "localhost" - it should NOT be there!

Search for "herataria.nova.af" - it SHOULD be there!

---

## Step 6: Upload to Server

Only if Step 4 passes (no localhost found):

1. Delete everything in server's `public_html/frontend/`
2. Upload contents of `dist\spa\` to `public_html/frontend/`
3. Test on server

---

## If .env Files Are Not Being Read

If the build still has localhost, edit the source file directly:

**frontend/src/boot/axios.js**

Change line 6-8:

**FROM:**
```javascript
const API_URL = (
  (typeof window !== 'undefined' && window.__ELECTRON_API_URL__) ||
  import.meta.env.VITE_API_URL ||
  'http://localhost:8000'
).replace(/\/$/, '')
```

**TO:**
```javascript
const API_URL = (
  (typeof window !== 'undefined' && window.__ELECTRON_API_URL__) ||
  import.meta.env.VITE_API_URL ||
  'https://herataria.nova.af/backend/public'
).replace(/\/$/, '')
```

Then rebuild:
```cmd
rmdir /s /q dist
npm run build
```

---

## Alternative: Force the URL

If nothing works, hardcode it:

**frontend/src/boot/axios.js**

Change to:

```javascript
// PRODUCTION BUILD - HARDCODED API URL
const API_URL = 'https://herataria.nova.af/backend/public'

const api = axios.create({
  baseURL: `${API_URL}/api`,
  withCredentials: true,
  withXSRFToken: true,
  headers: { Accept: 'application/json' }
})
```

This guarantees it will use the production URL!

---

## Test Command Sequence

Run these commands in order:

```cmd
cd C:\Users\khawa\Herd\Aria-Herat-Mohandes-Zada-Construction\frontend

echo Checking .env file...
type .env

echo Checking .env.production file...
type .env.production

echo Cleaning...
rmdir /s /q dist

echo Building...
npm run build

echo Verifying build...
cd dist\spa\assets
findstr /S "localhost:8000" *.js

echo If no localhost found, build is good!
```

---

## What To Tell Me

After running the commands above, tell me:

1. What does `type .env` show?
2. What does `type .env.production` show?
3. Did `findstr /S "localhost:8000" *.js` find anything?
4. If yes, paste what it found

Then I'll know exactly what's wrong!
