|
| 1 | +# 🔍 Hosting Troubleshooting Guide |
| 2 | + |
| 3 | +## Issue: Frontend Not Loading |
| 4 | + |
| 5 | +### What Was Fixed (October 22, 2025) |
| 6 | + |
| 7 | +1. **Added missing `REACT_APP_API_URL` to `.env.production`** |
| 8 | + - The frontend was trying to connect to `localhost:5000` in production |
| 9 | + - Now correctly points to: `https://skynest-backend-api.onrender.com/api` |
| 10 | + |
| 11 | +2. **Rebuilt and redeployed the application** |
| 12 | + - Clean build with production environment variables |
| 13 | + - Deployed to GitHub Pages at: https://nadeeshanj.github.io/Database-Project |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## How to Test Your Website |
| 18 | + |
| 19 | +### 1. Open the Website |
| 20 | +Visit: **https://nadeeshanj.github.io/Database-Project** |
| 21 | + |
| 22 | +### 2. Check Browser Console (IMPORTANT!) |
| 23 | +Press `F12` or right-click → "Inspect" → Go to "Console" tab |
| 24 | + |
| 25 | +**What to look for:** |
| 26 | +- ✅ **GOOD**: No errors, or only minor warnings |
| 27 | +- ❌ **BAD**: Red errors mentioning "localhost", "CORS", "Network Error" |
| 28 | + |
| 29 | +### 3. Test Login |
| 30 | +Try logging in with test credentials: |
| 31 | +- **Username**: `admin` |
| 32 | +- **Password**: `password123` |
| 33 | + |
| 34 | +**Expected behavior:** |
| 35 | +- Should redirect to dashboard |
| 36 | +- Should show hotel statistics |
| 37 | + |
| 38 | +### 4. Check Network Tab |
| 39 | +In browser dev tools (F12), go to "Network" tab: |
| 40 | +- Look for API calls going to `skynest-backend-api.onrender.com` |
| 41 | +- ✅ **GOOD**: Status 200 (or 201) |
| 42 | +- ⚠️ **WARNING**: Status 504 (Gateway Timeout - backend is waking up) |
| 43 | +- ❌ **BAD**: Status 0 (CORS issue) or calls to `localhost` |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## Common Issues & Solutions |
| 48 | + |
| 49 | +### Issue 1: "Site Not Loading / White Screen" |
| 50 | + |
| 51 | +**Possible Causes:** |
| 52 | +1. Browser cache showing old version |
| 53 | +2. GitHub Pages hasn't updated yet (takes 1-2 minutes) |
| 54 | + |
| 55 | +**Solutions:** |
| 56 | +```bash |
| 57 | +# Hard refresh in browser |
| 58 | +Windows: Ctrl + Shift + R |
| 59 | +Mac: Cmd + Shift + R |
| 60 | + |
| 61 | +# Or clear browser cache: |
| 62 | +Windows: Ctrl + Shift + Delete |
| 63 | +Mac: Cmd + Shift + Delete |
| 64 | +``` |
| 65 | + |
| 66 | +### Issue 2: "API Calls Failing" |
| 67 | + |
| 68 | +**Check this in Console (F12):** |
| 69 | +``` |
| 70 | +If you see: "localhost:5000" in any error |
| 71 | +→ Build wasn't done with production env variables |
| 72 | +
|
| 73 | +If you see: "CORS policy blocked" |
| 74 | +→ Backend CORS settings need updating |
| 75 | +``` |
| 76 | + |
| 77 | +**Solution:** |
| 78 | +```bash |
| 79 | +# In Database-Project folder |
| 80 | +cd "c:\Users\nadee\Documents\Database-Project" |
| 81 | + |
| 82 | +# Clean and rebuild |
| 83 | +Remove-Item -Recurse -Force build |
| 84 | +npm run build |
| 85 | +npm run deploy |
| 86 | +``` |
| 87 | + |
| 88 | +### Issue 3: "Backend Taking Too Long (504 Error)" |
| 89 | + |
| 90 | +**This is NORMAL for Render free tier!** |
| 91 | +- Backend spins down after 15 minutes of inactivity |
| 92 | +- First request can take 30-60 seconds to wake up |
| 93 | +- Just wait and try again |
| 94 | + |
| 95 | +**What you'll see:** |
| 96 | +1. First API call: 504 Gateway Timeout |
| 97 | +2. Wait 30 seconds |
| 98 | +3. Try again: Should work |
| 99 | + |
| 100 | +### Issue 4: "Cannot Login / Authentication Failed" |
| 101 | + |
| 102 | +**Check:** |
| 103 | +1. Are you using correct credentials? (see test credentials below) |
| 104 | +2. Is backend actually running? |
| 105 | +3. Check browser console for error details |
| 106 | + |
| 107 | +**Test Backend:** |
| 108 | +```bash |
| 109 | +# In PowerShell |
| 110 | +curl https://skynest-backend-api.onrender.com/api/health |
| 111 | +``` |
| 112 | + |
| 113 | +**Expected Response:** |
| 114 | +```json |
| 115 | +{ |
| 116 | + "success": true, |
| 117 | + "message": "Hotel Management API is running", |
| 118 | + "timestamp": "2025-10-22T...", |
| 119 | + "environment": "production" |
| 120 | +} |
| 121 | +``` |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +## Test Credentials |
| 126 | + |
| 127 | +### Admin Account |
| 128 | +- **Username**: `admin` |
| 129 | +- **Password**: `password123` |
| 130 | +- **Access**: Full system access |
| 131 | + |
| 132 | +### Branch Managers |
| 133 | +- `manager_colombo` / `password123` (Colombo Branch) |
| 134 | +- `manager_kandy` / `password123` (Kandy Branch) |
| 135 | +- `manager_galle` / `password123` (Galle Branch) |
| 136 | + |
| 137 | +### Receptionists |
| 138 | +- `recept_colombo` / `password123` |
| 139 | +- `recept_kandy` / `password123` |
| 140 | +- `recept_galle` / `password123` |
| 141 | + |
| 142 | +### Accountants |
| 143 | +- `accountant_colombo` / `password123` |
| 144 | +- `accountant_kandy` / `password123` |
| 145 | +- `accountant_galle` / `password123` |
| 146 | + |
| 147 | +--- |
| 148 | + |
| 149 | +## Verification Checklist |
| 150 | + |
| 151 | +Use this checklist to verify everything is working: |
| 152 | + |
| 153 | +### Frontend (GitHub Pages) |
| 154 | +- [ ] Website loads at https://nadeeshanj.github.io/Database-Project |
| 155 | +- [ ] Landing page displays correctly |
| 156 | +- [ ] Login button is visible and clickable |
| 157 | +- [ ] No console errors related to "localhost" |
| 158 | +- [ ] Browser console shows API calls to `skynest-backend-api.onrender.com` |
| 159 | + |
| 160 | +### Backend (Render) |
| 161 | +- [ ] Health check works: https://skynest-backend-api.onrender.com/api/health |
| 162 | +- [ ] Returns JSON response with `"success": true` |
| 163 | +- [ ] Status code is 200 |
| 164 | + |
| 165 | +### Full Integration |
| 166 | +- [ ] Can login with admin credentials |
| 167 | +- [ ] Dashboard loads with statistics |
| 168 | +- [ ] Can view guests, rooms, bookings pages |
| 169 | +- [ ] Data is loading from backend (not empty) |
| 170 | +- [ ] No CORS errors in console |
| 171 | + |
| 172 | +--- |
| 173 | + |
| 174 | +## How to Redeploy (If Needed) |
| 175 | + |
| 176 | +### Frontend Only |
| 177 | +```powershell |
| 178 | +cd "c:\Users\nadee\Documents\Database-Project" |
| 179 | +npm run deploy |
| 180 | +``` |
| 181 | + |
| 182 | +### Backend (Render Auto-Deploys) |
| 183 | +Just push to GitHub main branch: |
| 184 | +```bash |
| 185 | +cd "c:\Users\nadee\Documents\Database-Back" |
| 186 | +git add . |
| 187 | +git commit -m "Your message" |
| 188 | +git push origin main |
| 189 | +``` |
| 190 | + |
| 191 | +Render will automatically detect the push and redeploy (takes 3-5 minutes). |
| 192 | + |
| 193 | +--- |
| 194 | + |
| 195 | +## Environment Files Reference |
| 196 | + |
| 197 | +### Frontend `.env.production` (CRITICAL!) |
| 198 | +```env |
| 199 | +REACT_APP_API_BASE=https://skynest-backend-api.onrender.com |
| 200 | +REACT_APP_API_URL=https://skynest-backend-api.onrender.com/api |
| 201 | +REACT_APP_APP_NAME=Hotel Management System |
| 202 | +REACT_APP_VERSION=1.0.0 |
| 203 | +REACT_APP_ENV=production |
| 204 | +REACT_APP_DEBUG=false |
| 205 | +``` |
| 206 | + |
| 207 | +### Backend `.env` (On Render Dashboard) |
| 208 | +```env |
| 209 | +NODE_ENV=production |
| 210 | +PORT=10000 |
| 211 | +DATABASE_URL=<your-render-database-url> |
| 212 | +JWT_SECRET=<your-secret> |
| 213 | +JWT_EXPIRES_IN=24h |
| 214 | +FRONTEND_URL=https://nadeeshanj.github.io |
| 215 | +DB_SSL=true |
| 216 | +``` |
| 217 | + |
| 218 | +--- |
| 219 | + |
| 220 | +## Still Not Working? |
| 221 | + |
| 222 | +### Step 1: Check Current Status |
| 223 | +```powershell |
| 224 | +# Test frontend |
| 225 | +curl https://nadeeshanj.github.io/Database-Project/ |
| 226 | +
|
| 227 | +# Test backend |
| 228 | +curl https://skynest-backend-api.onrender.com/api/health |
| 229 | +``` |
| 230 | + |
| 231 | +### Step 2: Review Deployment |
| 232 | +```powershell |
| 233 | +cd "c:\Users\nadee\Documents\Database-Project" |
| 234 | +
|
| 235 | +# Check if .env.production has REACT_APP_API_URL |
| 236 | +Get-Content .env.production | Select-String "API_URL" |
| 237 | +
|
| 238 | +# Check last deployment |
| 239 | +git log origin/gh-pages --oneline -1 |
| 240 | +``` |
| 241 | + |
| 242 | +### Step 3: Force Fresh Deployment |
| 243 | +```powershell |
| 244 | +# Clean everything |
| 245 | +Remove-Item -Recurse -Force build |
| 246 | +Remove-Item -Recurse -Force node_modules/.cache -ErrorAction SilentlyContinue |
| 247 | +
|
| 248 | +# Fresh build and deploy |
| 249 | +npm run build |
| 250 | +npm run deploy |
| 251 | +``` |
| 252 | + |
| 253 | +### Step 4: Clear Browser Cache |
| 254 | +- Chrome/Edge: `Ctrl + Shift + Delete` → Clear browsing data |
| 255 | +- Select "Cached images and files" |
| 256 | +- Time range: "All time" |
| 257 | +- Click "Clear data" |
| 258 | + |
| 259 | +### Step 5: Wait for Propagation |
| 260 | +- GitHub Pages can take 1-2 minutes to update |
| 261 | +- Try in incognito/private mode |
| 262 | +- Try on different device or network |
| 263 | + |
| 264 | +--- |
| 265 | + |
| 266 | +## Contact Information |
| 267 | + |
| 268 | +If problems persist: |
| 269 | +1. Check GitHub Actions for deployment status |
| 270 | +2. Review Render dashboard for backend logs |
| 271 | +3. Check browser console for specific error messages |
| 272 | +4. Verify environment variables are set correctly |
| 273 | + |
| 274 | +--- |
| 275 | + |
| 276 | +## Last Successful Deployment |
| 277 | + |
| 278 | +- **Date**: October 22, 2025 |
| 279 | +- **Frontend**: https://nadeeshanj.github.io/Database-Project ✅ |
| 280 | +- **Backend**: https://skynest-backend-api.onrender.com ✅ |
| 281 | +- **Status**: Both services operational |
| 282 | + |
| 283 | +--- |
| 284 | + |
| 285 | +*Document created: October 22, 2025* |
| 286 | +*Last updated: October 22, 2025* |
0 commit comments