fix(polling): resolve mixed-content HTTP blocking and cache prevention for real-time polling

This commit is contained in:
Ray1111-aa
2026-10-29 14:40:11 +07:00
parent f7b92a1c71
commit b0469611d7
7 changed files with 17 additions and 9 deletions
@@ -204,7 +204,7 @@ class DashboardController extends Controller
'rejection_note' => $activity->rejection_note, 'rejection_note' => $activity->rejection_note,
'recorded_at' => $activity->recorded_at ? $activity->recorded_at->format('H:i') . ' WIB' : null, 'recorded_at' => $activity->recorded_at ? $activity->recorded_at->format('H:i') . ' WIB' : null,
'validated_at' => $activity->validated_at ? $activity->validated_at->format('H:i') . ' WIB' : null, 'validated_at' => $activity->validated_at ? $activity->validated_at->format('H:i') . ' WIB' : null,
]); ])->header('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
} }
/** /**
@@ -150,7 +150,7 @@ class GateInspectionController extends Controller
'count' => $pendingActivities->count(), 'count' => $pendingActivities->count(),
'items' => $items, 'items' => $items,
'html' => view('pg.partials.queue_cards', compact('pendingActivities', 'currentGuard', 'guards'))->render(), 'html' => view('pg.partials.queue_cards', compact('pendingActivities', 'currentGuard', 'guards'))->render(),
]); ])->header('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
} }
/** /**
+5
View File
@@ -23,6 +23,11 @@ class AppServiceProvider extends ServiceProvider
\Carbon\Carbon::setLocale('id'); \Carbon\Carbon::setLocale('id');
date_default_timezone_set(config('app.timezone', 'Asia/Jakarta')); date_default_timezone_set(config('app.timezone', 'Asia/Jakarta'));
// Deteksi HTTPS dari Cloudflare Reverse Proxy / Tunnel
if (request()->header('x-forwarded-proto') === 'https' || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') || str_starts_with(config('app.url'), 'https://')) {
\Illuminate\Support\Facades\URL::forceScheme('https');
}
// Super Admin bypass: secara otomatis memiliki izin untuk semua ability // Super Admin bypass: secara otomatis memiliki izin untuk semua ability
Gate::before(function ($user, $ability) { Gate::before(function ($user, $ability) {
if (in_array($user->role, ['super_admin', 'superadmin', 'admin'])) { if (in_array($user->role, ['super_admin', 'superadmin', 'admin'])) {
+1
View File
@@ -52,6 +52,7 @@ server {
fastcgi_pass app:9000; fastcgi_pass app:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params; include fastcgi_params;
fastcgi_param HTTP_X_FORWARDED_PROTO $http_x_forwarded_proto;
fastcgi_hide_header X-Powered-By; fastcgi_hide_header X-Powered-By;
fastcgi_buffers 16 16k; fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k; fastcgi_buffer_size 32k;
+3 -2
View File
@@ -1162,10 +1162,11 @@
isPollingInProgress = true; isPollingInProgress = true;
try { try {
const response = await fetch(`{{ route('employee.activity.status_polling') }}?activity_id=${activityId}`, { const response = await fetch(`{{ route('employee.activity.status_polling', [], false) }}?activity_id=${activityId}&_t=${Date.now()}`, {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest',
'Cache-Control': 'no-cache'
} }
}); });
+2 -2
View File
@@ -560,11 +560,11 @@
const pdfBtn = document.getElementById('modalDownloadPdfBtn'); const pdfBtn = document.getElementById('modalDownloadPdfBtn');
const tableBody = document.getElementById('modalItemsTableBody'); const tableBody = document.getElementById('modalItemsTableBody');
pdfBtn.href = "{{ url('/karyawan/riwayat/p2h') }}/" + recordId + "/pdf"; pdfBtn.href = "{{ url('/karyawan/riwayat/p2h', [], false) }}/" + recordId + "/pdf";
tableBody.innerHTML = '<tr><td colspan="4" class="py-4 text-center text-slate-400">Memuat data...</td></tr>'; tableBody.innerHTML = '<tr><td colspan="4" class="py-4 text-center text-slate-400">Memuat data...</td></tr>';
modal.classList.remove('hidden'); modal.classList.remove('hidden');
fetch("{{ url('/karyawan/riwayat/p2h') }}/" + recordId) fetch("{{ url('/karyawan/riwayat/p2h', [], false) }}/" + recordId)
.then(res => { .then(res => {
if (!res.ok) throw new Error('Gagal memuat detail data.'); if (!res.ok) throw new Error('Gagal memuat detail data.');
return res.json(); return res.json();
+4 -3
View File
@@ -344,10 +344,11 @@
isSyncing = true; isSyncing = true;
try { try {
const response = await fetch("{{ route('pg.gate.live_queue') }}?gate_id={{ $gate ? $gate->id : '' }}", { const response = await fetch("{{ route('pg.gate.live_queue', [], false) }}?gate_id={{ $gate ? $gate->id : '' }}&_t=" + Date.now(), {
headers: { headers: {
'X-Requested-With': 'XMLHttpRequest', 'X-Requested-With': 'XMLHttpRequest',
'Accept': 'application/json' 'Accept': 'application/json',
'Cache-Control': 'no-cache'
} }
}); });
@@ -404,7 +405,7 @@
// 3. Update Daftar Kartu Antrean Secara Halus (Hanya Jika Ada Perubahan) // 3. Update Daftar Kartu Antrean Secara Halus (Hanya Jika Ada Perubahan)
const listContainer = document.getElementById('queueListContainer'); const listContainer = document.getElementById('queueListContainer');
if (listContainer && lastQueueHtml !== null && lastQueueHtml !== data.html) { if (listContainer && data.html && lastQueueHtml !== data.html) {
listContainer.innerHTML = data.html; listContainer.innerHTML = data.html;
} }