forked from izu/student-web-if-development-kit
fix: use RODA dashboard proxy config
This commit is contained in:
+12
-3
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user