add sveltekit template
This commit is contained in:
parent
401e268281
commit
14f8e77e6a
24 changed files with 2157 additions and 1 deletions
15
Foxnouns.Frontend/src/hooks.server.ts
Normal file
15
Foxnouns.Frontend/src/hooks.server.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { PRIVATE_API_BASE } from "$env/static/private";
|
||||
import { PUBLIC_API_BASE } from "$env/static/public";
|
||||
|
||||
export async function handle({ event, resolve }) {
|
||||
event.locals.token = event.cookies.get("pronounscc-token");
|
||||
return await resolve(event);
|
||||
}
|
||||
|
||||
export function handleFetch({ event, request, fetch }) {
|
||||
if (request.url.startsWith(PUBLIC_API_BASE))
|
||||
request = new Request(request.url.replace(PUBLIC_API_BASE, PRIVATE_API_BASE), request);
|
||||
if (event.locals.token) request.headers.set("Authorization", event.locals.token);
|
||||
|
||||
return fetch(request);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue