diff --git a/frontend/src/lib/backend.ts b/frontend/src/lib/backend.ts index a9fc598d..ec2f25bd 100644 --- a/frontend/src/lib/backend.ts +++ b/frontend/src/lib/backend.ts @@ -1,6 +1,19 @@ export * from "./openapi"; export { DefaultService as Backend } from "./openapi"; import { OpenAPI } from "./openapi"; +import Cookies from "js-cookie"; export const BACKEND_URL = "http://localhost:8000"; OpenAPI.BASE = BACKEND_URL; + +// Sets the token header to the stored authentication token from the cookie +export function setToken() { + console.log("Setting Token") + OpenAPI.TOKEN = Cookies.get("auth") +} + +// Sets the token header to nothing. +export function clearToken() { + console.log("Clearing token.") + OpenAPI.TOKEN = undefined +} diff --git a/frontend/src/routes/Edit.svelte b/frontend/src/routes/Edit.svelte index 0a23cfad..0c22fee9 100644 --- a/frontend/src/routes/Edit.svelte +++ b/frontend/src/routes/Edit.svelte @@ -1,5 +1,5 @@