ui: align js with api
This commit is contained in:
+6
-2
@@ -1,12 +1,16 @@
|
||||
const BASE = __API_URL__
|
||||
|
||||
export async function requireAuth() {
|
||||
const res = await fetch('/api/whoami')
|
||||
const res = await fetch(`${BASE}/whoami`, { credentials: 'include' })
|
||||
if (res.status === 401) {
|
||||
window.location.href = '/login.html'
|
||||
return null
|
||||
}
|
||||
return res.text()
|
||||
}
|
||||
|
||||
export async function redirectIfAuthed() {
|
||||
const res = await fetch('/api/whoami')
|
||||
const res = await fetch(`${BASE}/whoami`, { credentials: 'include' })
|
||||
if (res.ok) {
|
||||
window.location.href = '/'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user