Skip to content

Commit 02cafa3

Browse files
committed
Add comments to handleFetch and only include cookie if it exists
1 parent 27c4b8a commit 02cafa3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/hooks.server.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,18 @@ export async function handle({ event, resolve }) {
2727

2828
/** @type {import('@sveltejs/kit').HandleFetch} */
2929
export async function handleFetch({ event, request, fetch }) {
30-
if (request.url.startsWith(FRACTAL_SERVER_HOST)) {
31-
console.log(`Modifying request to ${request.url}, via handleFetch`);
30+
/*
31+
See:
32+
1. https://github.com/fractal-analytics-platform/fractal-web/issues/274
33+
2. https://kit.svelte.dev/docs/hooks#server-hooks-handlefetch
34+
*/
35+
36+
if (
37+
request.url.startsWith(FRACTAL_SERVER_HOST) &&
38+
'headers' in request &&
39+
'cookie' in request.headers
40+
) {
41+
console.log(`Including cookie into request to ${request.url}, via handleFetch`);
3242
request.headers.set('cookie', event.request.headers.get('cookie'));
3343
}
3444
return fetch(request);

0 commit comments

Comments
 (0)