# Troubleshooting ERR_CONNECTION_RESET untuk Build Assets

## Masalah
Error `ERR_CONNECTION_RESET` saat loading file JavaScript/CSS dari `/build/assets/`

## Penyebab Umum
1. Server timeout saat mengirim file
2. Kompresi GZIP bermasalah
3. mod_security memblokir file
4. MIME type tidak tepat

## Solusi yang Sudah Diterapkan

### 1. .htaccess di public/
- ✅ Enable GZIP compression untuk JS/CSS
- ✅ Set proper MIME types
- ✅ Cache headers untuk performa

### 2. .htaccess di public/build/assets/
- ✅ Dedicated rules untuk build assets
- ✅ Disable rewrite engine
- ✅ CORS headers
- ✅ Immutable cache (1 year)

## Langkah di Hosting

### Setelah Git Pull:
```bash
cd /path/to/MN
git pull origin main

# Pastikan .htaccess ter-upload
ls -la public/.htaccess
ls -la public/build/assets/.htaccess

# Set permissions
chmod 644 public/.htaccess
chmod 644 public/build/assets/.htaccess
```

### Jika Masih Error:

#### 1. Cek mod_security
```bash
# Di cPanel > ModSecurity
# Disable untuk domain matematikanusantara.id
# Atau whitelist path /build/assets/
```

#### 2. Cek PHP Memory Limit
```bash
# Di .htaccess atau php.ini
php_value memory_limit 256M
```

#### 3. Clear Browser Cache
- Hard refresh: Ctrl+Shift+R (Windows) / Cmd+Shift+R (Mac)
- Clear all cache di browser

#### 4. Cek Error Log
```bash
tail -f /path/to/error_log
# Lihat error saat load halaman
```

#### 5. Test Direct Access
```bash
# Akses langsung file JS
curl -I https://matematikanusantara.id/build/assets/app-BKx5_l1k.js

# Harus return:
# HTTP/1.1 200 OK
# Content-Type: application/javascript
# Content-Encoding: gzip (jika compression aktif)
```

## Alternatif Solusi

### Jika .htaccess Tidak Bekerja:

#### 1. Disable GZIP di .htaccess
Hapus/comment section `mod_deflate` jika menyebabkan masalah

#### 2. Serve via PHP
Buat file `public/build/assets/serve.php`:
```php
<?php
$file = $_GET['file'] ?? '';
$path = __DIR__ . '/' . basename($file);

if (file_exists($path)) {
    header('Content-Type: application/javascript');
    header('Cache-Control: public, max-age=31536000');
    readfile($path);
    exit;
}
http_response_code(404);
```

#### 3. CDN/External Hosting
Upload build assets ke CDN jika server terus bermasalah

## Verifikasi Sukses
- ✅ Halaman load tanpa error di console
- ✅ Network tab menunjukkan status 200 untuk semua assets
- ✅ File JS/CSS ter-load sempurna
- ✅ Tidak ada error `ERR_CONNECTION_RESET`

## Kontak Support
Jika masih bermasalah, hubungi hosting support dengan info:
- Error: ERR_CONNECTION_RESET
- File: /build/assets/app-*.js
- Status: 200 OK tapi connection reset
- Request: Enable mod_deflate, mod_expires, mod_headers
