Skip to content

Commit 43c9047

Browse files
authored
Merge pull request #275 from fractal-analytics-platform/274-fix-cookie-issue
Add `handleFetch` hook, in order to propagate cookie
2 parents 6c97b16 + 3502268 commit 43c9047

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
*Note: Numbers like (\#123) point to closed Pull Requests on the fractal-web repository.*
22

33

4+
# 0.5.4
5+
6+
* Always propagate cookie for API calls to `FRACTAL_SERVER_HOST`, even for different domains (\#275).
7+
48
# 0.5.3
59

610
* Add confirmation dialog for delete-task operation (\#272).

src/hooks.server.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,19 @@ export async function handle({ event, resolve }) {
2323
return new Response(null, { status: 302, headers: { location: '/auth/login' } });
2424
}
2525
}
26+
27+
28+
/** @type {import('@sveltejs/kit').HandleFetch} */
29+
export async function handleFetch({ event, request, fetch }) {
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 (request.url.startsWith(FRACTAL_SERVER_HOST)) {
37+
console.log(`Including cookie into request to ${request.url}, via handleFetch`);
38+
request.headers.set('cookie', event.request.headers.get('cookie'));
39+
}
40+
return fetch(request);
41+
}

0 commit comments

Comments
 (0)