feat(RODA): data riset kini real-time via proxy Netlify
This commit is contained in:
@@ -76,7 +76,7 @@
|
||||
window.APP_CONFIG = window.APP_CONFIG || {
|
||||
debugLogs: false,
|
||||
dashboardRuntimeFetch: 'always',
|
||||
dashboardApiUrl: 'api/dashboard',
|
||||
dashboardApiUrl: 'https://proxykbk.netlify.app/.netlify/functions/dashboard',
|
||||
};
|
||||
</script>
|
||||
<!-- RODA_DASHBOARD_DATA -->
|
||||
|
||||
+15
-2
@@ -146,17 +146,30 @@ const server = http.createServer((req, res) => {
|
||||
}
|
||||
|
||||
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()
|
||||
.then(({ html, cached }) => {
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'text/html; charset=utf-8',
|
||||
'X-Cache': cached
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'X-Cache': cached,
|
||||
});
|
||||
res.end(html);
|
||||
})
|
||||
.catch((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');
|
||||
});
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user