f
This commit is contained in:
@@ -6,6 +6,7 @@ async function request<T>(path: string, options: RequestInit = {}): Promise<T> {
|
|||||||
|
|
||||||
const res = await fetch(`${API_URL}${path}`, {
|
const res = await fetch(`${API_URL}${path}`, {
|
||||||
...options,
|
...options,
|
||||||
|
credentials: 'include',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-CSRF-Token': token,
|
'X-CSRF-Token': token,
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ let cachedToken: string | null = null
|
|||||||
|
|
||||||
export async function getCsrfToken(): Promise<string> {
|
export async function getCsrfToken(): Promise<string> {
|
||||||
if (cachedToken) return cachedToken
|
if (cachedToken) return cachedToken
|
||||||
const res = await fetch(`${API_URL}/csrf/token`)
|
const res = await fetch(`${API_URL}/csrf/token`, {
|
||||||
|
credentials: 'include',
|
||||||
|
})
|
||||||
const data: CsrfResponse = await res.json()
|
const data: CsrfResponse = await res.json()
|
||||||
cachedToken = data.token
|
cachedToken = data.token
|
||||||
return cachedToken
|
return cachedToken
|
||||||
|
|||||||
Reference in New Issue
Block a user