1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-26 00:09:38 +02:00
AdventureLog/frontend/src/lib/index.server.ts

12 lines
374 B
TypeScript

const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
const serverEndpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
export const fetchCSRFToken = async () => {
const csrfTokenFetch = await fetch(`${serverEndpoint}/csrf/`);
if (csrfTokenFetch.ok) {
const csrfToken = await csrfTokenFetch.json();
return csrfToken.csrfToken;
} else {
return null;
}
};