feat(RODA): data riset kini real-time via proxy Netlify

This commit is contained in:
GuavaPopper
2026-06-05 20:16:53 +07:00
parent d772f4573b
commit 00611a921b
2 changed files with 16 additions and 3 deletions
+1 -1
View File
@@ -76,7 +76,7 @@
window.APP_CONFIG = window.APP_CONFIG || { window.APP_CONFIG = window.APP_CONFIG || {
debugLogs: false, debugLogs: false,
dashboardRuntimeFetch: 'always', dashboardRuntimeFetch: 'always',
dashboardApiUrl: 'api/dashboard', dashboardApiUrl: 'https://proxykbk.netlify.app/.netlify/functions/dashboard',
}; };
</script> </script>
<!-- RODA_DASHBOARD_DATA --> <!-- RODA_DASHBOARD_DATA -->
+15 -2
View File
@@ -146,17 +146,30 @@ const server = http.createServer((req, res) => {
} }
if (pathname === '/api/dashboard' || pathname === `${RODA_PATH_PREFIX}/api/dashboard`) { if (pathname === '/api/dashboard' || pathname === `${RODA_PATH_PREFIX}/api/dashboard`) {
if (req.method === 'OPTIONS') {
res.writeHead(204, {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET',
});
res.end();
return;
}
fetchDashboardHtml() fetchDashboardHtml()
.then(({ html, cached }) => { .then(({ html, cached }) => {
res.writeHead(200, { res.writeHead(200, {
'Content-Type': 'text/html; charset=utf-8', 'Content-Type': 'text/html; charset=utf-8',
'X-Cache': cached 'Access-Control-Allow-Origin': '*',
'X-Cache': cached,
}); });
res.end(html); res.end(html);
}) })
.catch((error) => { .catch((error) => {
logServerError('api-dashboard', error); logServerError('api-dashboard', error);
res.writeHead(502, { 'Content-Type': 'text/plain; charset=utf-8' }); res.writeHead(502, {
'Content-Type': 'text/plain; charset=utf-8',
'Access-Control-Allow-Origin': '*',
});
res.end('DASHBOARD_FETCH_FAILED'); res.end('DASHBOARD_FETCH_FAILED');
}); });
return; return;