Skip to content

Commit

Permalink
fix: use base uri for api health check
Browse files Browse the repository at this point in the history
  • Loading branch information
thekiba committed Jul 31, 2024
1 parent 2aec8c9 commit 2462c0e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {runSingleInstance} from "./utils/run-signle-instance";
eruda.init();

async function enableMocking() {
const host = document.baseURI.replace(/\/$/, '');

return new Promise(async (resolve) => {
const {worker} = await import('./server/worker');

Expand All @@ -29,7 +31,7 @@ async function enableMocking() {
const serviceWorkerRegistrations = await navigator.serviceWorker?.getRegistrations() || [];

const isServiceWorkerOk = serviceWorkerRegistrations.length > 0;
const isApiOk = await fetch('/api/healthz')
const isApiOk = await fetch(`${host}/api/healthz`)
.then(r => r.status === 200 ? r.json().then(p => p.ok).catch(() => false) : false)
.catch(() => false);

Expand All @@ -52,4 +54,4 @@ enableMocking().then(() => render(
<App/>
</StrictMode>,
document.getElementById('root') as HTMLElement
));
));

0 comments on commit 2462c0e

Please sign in to comment.