fix: use RODA dashboard proxy config

This commit is contained in:
Raditya_Indra_Putranto
2026-06-04 19:03:28 +07:00
parent 1d5b807fc7
commit 3b749e4c99
3 changed files with 12 additions and 80 deletions
+12 -3
View File
@@ -1541,6 +1541,11 @@
return rows;
}
function shouldUseLocalDashboardProxy() {
const hostname = window.location.hostname;
return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '';
}
async function fetchDashboardData() {
const grid = document.getElementById('riset-grid');
if (grid) {
@@ -1557,10 +1562,10 @@
? window.APP_CONFIG.dashboardProxyTemplates.filter(Boolean)
: [];
// Sumber utama: endpoint proxy lokal (server.js fetch server-side, tanpa CORS).
const proxyServers = [() => '/api/dashboard'];
// Endpoint server.js hanya ada saat development lokal.
const proxyServers = shouldUseLocalDashboardProxy() ? [() => '/api/dashboard'] : [];
// Fallback: proxy publik (butuh targetUrl untuk membangun URL).
// Deployment static memakai proxy publik karena tidak menjalankan server.js.
if (targetUrl) {
proxyTemplates.forEach((template) => {
proxyServers.push((url) => template
@@ -1570,6 +1575,10 @@
});
}
if (!proxyServers.length) {
throw new Error('DASHBOARD_PROXY_NOT_CONFIGURED');
}
let lastError = null;
for (const getProxyUrl of proxyServers) {