mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 10:51:36 +01:00
Fix JWT signature error for initial fetch request
This commit is contained in:
@@ -5,7 +5,8 @@ export const handle = async ({ event, resolve }) => {
|
|||||||
if (!event.url.pathname.startsWith("/api/")) {
|
if (!event.url.pathname.startsWith("/api/")) {
|
||||||
const userData = await apiRequest(event.fetch, `${API_BASE_PREFIX}/account`, "GET", {
|
const userData = await apiRequest(event.fetch, `${API_BASE_PREFIX}/account`, "GET", {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/vnd.pgrst.object+json"
|
Accept: "application/vnd.pgrst.object+json",
|
||||||
|
Authorization: `Bearer ${event.cookies.get("session_token")}`
|
||||||
},
|
},
|
||||||
returnData: true
|
returnData: true
|
||||||
});
|
});
|
||||||
@@ -27,10 +28,8 @@ export const handle = async ({ event, resolve }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const handleFetch = async ({ event, request, fetch }) => {
|
export const handleFetch = async ({ event, request, fetch }) => {
|
||||||
const sessionToken = event.cookies.get("session_token");
|
if (event.locals.user) {
|
||||||
|
request.headers.set("Authorization", `Bearer ${event.cookies.get("session_token")}`);
|
||||||
if (sessionToken) {
|
|
||||||
request.headers.set("Authorization", `Bearer ${sessionToken}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fetch(request);
|
return fetch(request);
|
||||||
|
|||||||
@@ -42,10 +42,14 @@
|
|||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<div class="logo-wrapper">
|
{#if data.user}
|
||||||
|
<div class="logo-wrapper">
|
||||||
|
<img src="/favicon.svg" width="24" height="24" alt="" />
|
||||||
|
<a href="/">archtika</a>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
<img src="/favicon.svg" width="24" height="24" alt="" />
|
<img src="/favicon.svg" width="24" height="24" alt="" />
|
||||||
<a href="/">archtika</a>
|
{/if}
|
||||||
</div>
|
|
||||||
<ul class="link-wrapper unpadded">
|
<ul class="link-wrapper unpadded">
|
||||||
{#if data.user}
|
{#if data.user}
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
Reference in New Issue
Block a user