2025-12-22 02:36:48 +01:00
|
|
|
import type { AccountOrg } from '$features/app/types';
|
2025-08-05 17:40:31 +01:00
|
|
|
import type { MetaTagsProps } from 'svelte-meta-tags';
|
2025-10-11 13:27:50 +01:00
|
|
|
import { PUBLIC_IS_SELFHOSTED } from '$env/static/public';
|
2026-03-09 11:18:22 +01:00
|
|
|
import { getBaseMetaTags } from '$lib/utils/functions/metaTags';
|
2026-03-11 12:01:26 +01:00
|
|
|
import { getOrgSiteInfo } from '$features/app/layout-setup';
|
2023-08-14 06:22:03 +01:00
|
|
|
|
2026-03-28 22:39:06 +01:00
|
|
|
export const ssr = true;
|
2025-05-03 14:46:01 +01:00
|
|
|
|
2023-10-29 12:07:34 +00:00
|
|
|
interface LoadOutput {
|
|
|
|
|
orgSiteName: string;
|
|
|
|
|
isOrgSite: boolean;
|
|
|
|
|
skipAuth: boolean;
|
2025-12-02 09:54:38 +01:00
|
|
|
org: AccountOrg | null;
|
2024-08-01 14:04:50 +01:00
|
|
|
baseMetaTags: MetaTagsProps;
|
2024-12-28 23:11:55 +01:00
|
|
|
serverLang: string;
|
2026-03-09 11:18:22 +01:00
|
|
|
localeCookie: string;
|
2025-11-24 01:00:50 +01:00
|
|
|
locals: App.Locals;
|
2023-10-29 12:07:34 +00:00
|
|
|
}
|
|
|
|
|
|
2025-11-24 01:00:50 +01:00
|
|
|
export const load = async ({ url, cookies, request, locals }): Promise<LoadOutput> => {
|
2026-03-09 11:18:22 +01:00
|
|
|
const loadStart = performance.now();
|
2025-11-24 01:00:50 +01:00
|
|
|
const debugPlay = cookies.get('debugPlay');
|
|
|
|
|
|
2026-03-09 11:18:22 +01:00
|
|
|
const orgSiteInfoStart = performance.now();
|
2025-11-24 01:00:50 +01:00
|
|
|
const orgSiteInfo = await getOrgSiteInfo(url, cookies);
|
2026-03-09 11:18:22 +01:00
|
|
|
const orgSiteInfoMs = Math.round((performance.now() - orgSiteInfoStart) * 100) / 100;
|
2025-01-06 03:36:00 +01:00
|
|
|
|
2023-12-03 16:29:27 +03:00
|
|
|
const response: LoadOutput = {
|
2025-11-24 01:00:50 +01:00
|
|
|
orgSiteName: orgSiteInfo.orgSiteName,
|
|
|
|
|
isOrgSite: orgSiteInfo.isOrgSite,
|
|
|
|
|
skipAuth: orgSiteInfo.subdomain === 'play' || debugPlay === 'true',
|
|
|
|
|
org: orgSiteInfo.org,
|
2026-03-09 11:18:22 +01:00
|
|
|
baseMetaTags: getBaseMetaTags(url, orgSiteInfo),
|
2025-11-24 01:00:50 +01:00
|
|
|
serverLang: request.headers?.get('accept-language') || '',
|
2026-03-09 11:18:22 +01:00
|
|
|
localeCookie: cookies.get('classroomio_locale') || '',
|
2025-11-24 01:00:50 +01:00
|
|
|
locals
|
2023-08-14 06:22:03 +01:00
|
|
|
};
|
|
|
|
|
|
2026-03-09 11:18:22 +01:00
|
|
|
const loadMs = Math.round((performance.now() - loadStart) * 100) / 100;
|
|
|
|
|
console.log(
|
|
|
|
|
`[+layout.server] load: ${loadMs}ms (getOrgSiteInfo: ${orgSiteInfoMs}ms) | PUBLIC_IS_SELFHOSTED=${PUBLIC_IS_SELFHOSTED}`
|
|
|
|
|
);
|
2025-01-06 03:36:00 +01:00
|
|
|
|
2025-11-24 01:00:50 +01:00
|
|
|
// If it isn't a registered dashboard domain and also not a valid sub domain.
|
2026-03-09 11:18:22 +01:00
|
|
|
// if (!APP_SUBDOMAINS.includes(orgSiteInfo.subdomain) && !dev && !orgSiteInfo.isOrgSite) {
|
|
|
|
|
// redirect(307, 'https://app.classroomio.com');
|
|
|
|
|
// }
|
2023-08-14 06:22:03 +01:00
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
};
|