mirror of
https://github.com/ershisan99/coolify.git
synced 2026-01-25 20:52:10 +00:00
fix: cleanupStuckedContainers
This commit is contained in:
43
apps/trpc-experimental/client/src/routes/+layout.ts
Normal file
43
apps/trpc-experimental/client/src/routes/+layout.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { trpc } from '$lib/store';
|
||||
import type { LayoutLoad } from './$types';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import Cookies from 'js-cookie';
|
||||
export const ssr = false;
|
||||
|
||||
export const load: LayoutLoad = async ({ url }) => {
|
||||
const { pathname } = new URL(url);
|
||||
|
||||
try {
|
||||
if (pathname === '/login' || pathname === '/register') {
|
||||
const baseSettings = await trpc.settings.getBaseSettings.query();
|
||||
return {
|
||||
settings: {
|
||||
...baseSettings
|
||||
}
|
||||
};
|
||||
}
|
||||
const settings = await trpc.settings.getInstanceSettings.query();
|
||||
if (settings.data.token) {
|
||||
Cookies.set('token', settings.data.token);
|
||||
}
|
||||
return {
|
||||
settings: {
|
||||
...settings
|
||||
}
|
||||
};
|
||||
} catch (err) {
|
||||
if (err?.data?.httpStatus == 401) {
|
||||
throw redirect(307, '/login');
|
||||
}
|
||||
if (err instanceof Error) {
|
||||
throw error(500, {
|
||||
message: 'An unexpected error occurred, please try again later.' + '<br><br>' + err.message
|
||||
});
|
||||
}
|
||||
|
||||
throw error(500, {
|
||||
message: 'An unexpected error occurred, please try again later.'
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user