Skip to content

Commit

Permalink
Merge pull request #275 from fractal-analytics-platform/274-fix-cooki…
Browse files Browse the repository at this point in the history
…e-issue

Add `handleFetch` hook, in order to propagate cookie
  • Loading branch information
mfranzon authored Sep 4, 2023
2 parents 6c97b16 + 3502268 commit 43c9047
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
*Note: Numbers like (\#123) point to closed Pull Requests on the fractal-web repository.*


# 0.5.4

* Always propagate cookie for API calls to `FRACTAL_SERVER_HOST`, even for different domains (\#275).

# 0.5.3

* Add confirmation dialog for delete-task operation (\#272).
Expand Down
16 changes: 16 additions & 0 deletions src/hooks.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,19 @@ export async function handle({ event, resolve }) {
return new Response(null, { status: 302, headers: { location: '/auth/login' } });
}
}


/** @type {import('@sveltejs/kit').HandleFetch} */
export async function handleFetch({ event, request, fetch }) {
/*
See:
1. https://github.com/fractal-analytics-platform/fractal-web/issues/274
2. https://kit.svelte.dev/docs/hooks#server-hooks-handlefetch
*/

if (request.url.startsWith(FRACTAL_SERVER_HOST)) {
console.log(`Including cookie into request to ${request.url}, via handleFetch`);
request.headers.set('cookie', event.request.headers.get('cookie'));
}
return fetch(request);
}

0 comments on commit 43c9047

Please sign in to comment.