diff options
| author | Guillermo Serrahima <dev@vylion.com> | 2026-03-12 11:09:46 +0100 |
|---|---|---|
| committer | Guillermo Serrahima <dev@vylion.com> | 2026-03-12 11:09:46 +0100 |
| commit | 20abd199c381eeab138563af897b54ecadc57bae (patch) | |
| tree | f1340c1d9e13585fcfd29f9fab2280fcd889387b /frontend/src/main.ts | |
| parent | 60a0ae44cdf9bece1c15f20386e2ffdf80d80e96 (diff) | |
| download | llostre-20abd199c381eeab138563af897b54ecadc57bae.tar.xz llostre-20abd199c381eeab138563af897b54ecadc57bae.zip | |
Implemented OAuth login
Diffstat (limited to 'frontend/src/main.ts')
| -rw-r--r-- | frontend/src/main.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 20c3bea..4868365 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -68,6 +68,14 @@ function renderAuthor(note: any): string { } async function main() { + const sessionCheck = await fetch('/api/session', { + credentials: 'include' + }); + if (!sessionCheck.ok) { + window.location.href = '/login.html'; + throw new Error('not authenticated'); + } + const app = document.querySelector('#app'); if (!app) { console.error('App container not found'); @@ -77,7 +85,9 @@ async function main() { app.innerHTML = '<div class="spinner"></div>'; try { - const response = await fetch('http://localhost:8080/api/posts'); + const response = await fetch('/api/posts', { + credentials: 'include' + }); if (!response.ok) throw new Error(`HTTP ${response.status}`); const notes = await response.json(); |
