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

13 lines
374 B
TypeScript
Raw Normal View History

2024-07-08 11:44:39 -04:00
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;
}
};