diff --git a/src/main.tsx b/src/main.tsx new file mode 100644 index 0000000..55a81f2 --- /dev/null +++ b/src/main.tsx @@ -0,0 +1,33 @@ +import React from 'react' +import ReactDOM from 'react-dom/client' +import { registerSW } from 'virtual:pwa-register' +import { App } from './App' +import './styles.css' + +async function bootstrap() { + registerSW({ immediate: true }) + + const session = await fetch('/api/session', { headers: { Accept: 'application/json' } }) + if (session.status === 401) { + window.location.assign('/auth/login') + return + } + if (!session.ok) throw new Error(`Session check failed: ${session.status}`) + + const payload = await session.json() + ReactDOM.createRoot(document.getElementById('root')!).render( + + + + ) +} + +bootstrap().catch(error => { + document.body.innerHTML = ` +
+

Template Studio

+

Unable to start the application.

+
${String(error)}
+
+ ` +})