fix: authorization / registration

This commit is contained in:
2026-05-10 19:43:29 +03:00
parent 5ed79d8282
commit 9709bb9d7b

View File

@@ -9,7 +9,13 @@ export const tokenStore = {
const REFRESH_URL = 'https://app.auth.elcsa.ru/v1/jwt/refresh'
export async function refreshAccessToken(): Promise<string> {
const res = await fetch(REFRESH_URL, { method: 'POST', credentials: 'include' })
const { getCsrfToken } = await import('./csrf')
const csrf = await getCsrfToken()
const res = await fetch(REFRESH_URL, {
method: 'POST',
credentials: 'include',
headers: { 'X-CSRF-Token': csrf },
})
if (!res.ok) throw new Error('Unauthorized')
const data = await res.json()
tokenStore.set(data.access_token)