mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-26 13:31:45 +00:00
feat: ssr fetch hook
This commit is contained in:
parent
11455ac9f5
commit
dfd746be5a
1 changed files with 15 additions and 0 deletions
15
frontend/src/hooks.server.ts
Normal file
15
frontend/src/hooks.server.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import type { HandleFetch } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
export const handleFetch: HandleFetch = async ({ request, fetch, event,}) => {
|
||||||
|
console.log(`SSR: handleFetch() BEFORE: ${request.method} ${request.url}`);
|
||||||
|
|
||||||
|
const cookie = event.request.headers.get('cookie') || '';
|
||||||
|
|
||||||
|
request.headers.set('cookie', cookie);
|
||||||
|
|
||||||
|
request.headers.append('Origin', event.url.origin);
|
||||||
|
|
||||||
|
console.log(`SSR: handleFetch() AFTER: ${request.method} ${request.url}`);
|
||||||
|
|
||||||
|
return fetch(request);
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue