I used the classic scheme with async onMount fetching. This works pretty well but now I want to use recommended way with Svelte's Kit load fetch.
In ssr mode I can't get the cookie data. I tried to use Hooks (External Fetch) but headers are empty.
Can this moment be resolved?
hooks.ts
/** @type {import('@sveltejs/kit').ExternalFetch} */
export async function externalFetch(request: any) {
let headers: object = {}
const token: string | undefined = parse(request.headers.get('Cookie'))['jwt'] || undefined;
if (token){
headers = {headers: {'Authorization': 'Bearer ' + jwt}};
}
return fetch(request, headers);
}