fix(web): sharing of access token in server API ()

This commit is contained in:
Michel Heusschen 2023-02-24 21:42:20 +01:00 committed by GitHub
parent 3ea107be5a
commit cc6253ba38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 43 additions and 58 deletions

View file

@ -1,7 +1,14 @@
import type { Handle, HandleServerError } from '@sveltejs/kit';
import { AxiosError } from 'axios';
import { env } from '$env/dynamic/public';
import { ImmichApi } from './api/api';
export const handle = (async ({ event, resolve }) => {
event.locals.api = new ImmichApi({
basePath: env.PUBLIC_IMMICH_SERVER_URL || 'http://immich-server:3001',
accessToken: event.cookies.get('immich_access_token')
});
export const handle: Handle = async ({ event, resolve }) => {
const res = await resolve(event);
// The link header can grow quite big and has caused issues with our nginx
@ -9,7 +16,7 @@ export const handle: Handle = async ({ event, resolve }) => {
res.headers.delete('Link');
return res;
};
}) satisfies Handle;
export const handleError: HandleServerError = async ({ error }) => {
const httpError = error as AxiosError;