* feat: make upload file size limits configurable via .env Add UPLOAD_MAX_*_MB environment variables for documents, images, videos, exercise assignment files, AI assistant documents, landing page images, and media thumbnails. API presign routes validate file size server-side; dashboard UI reads the same limits from layout data. * chore: wire upload limit env vars through Docker compose and docs Pass UPLOAD_MAX_*_MB from the root .env into api and dashboard containers in both compose files, document them in .env.example and self-hosting guides. Co-authored-by: Rotimi Best <[email protected]> * docs: cross-link upload limits in README, Railway, Coolify, and Cloudflare guides Co-authored-by: Rotimi Best <[email protected]> * fix: address PR review feedback on upload limits - Restore 5 MB default for thumbnail uploads (edit-asset-dialog regression) - Add getResolvedUploadLimits() fallback for Storybook/tests - Cache core getUploadLimits() like the dashboard helper - Document presign fileSize as advisory; allow zero-byte fileSize in schema - Only send fileSize to presign when greater than zero * docs: remove upload limits from Cloudflare setup guide ---------
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
import type { AccountOrg } from '$features/app/types';
|
|
import type { MetaTagsProps } from 'svelte-meta-tags';
|
|
import type { UploadLimits } from '$lib/utils/config/upload-limits';
|
|
import { PUBLIC_IS_SELFHOSTED } from '$env/static/public';
|
|
import { getBaseMetaTags } from '$lib/utils/functions/metaTags';
|
|
import { getOrgSiteInfo } from '$features/app/layout-setup';
|
|
import { getUploadLimits } from '$lib/utils/config/upload-limits';
|
|
|
|
export const ssr = true;
|
|
|
|
interface LoadOutput {
|
|
orgSiteName: string;
|
|
isOrgSite: boolean;
|
|
skipAuth: boolean;
|
|
org: AccountOrg | null;
|
|
baseMetaTags: MetaTagsProps;
|
|
serverLang: string;
|
|
localeCookie: string;
|
|
locals: App.Locals;
|
|
uploadLimits: UploadLimits;
|
|
}
|
|
|
|
export const load = async ({ url, cookies, request, locals }): Promise<LoadOutput> => {
|
|
const loadStart = performance.now();
|
|
const debugPlay = cookies.get('debugPlay');
|
|
|
|
const orgSiteInfoStart = performance.now();
|
|
const orgSiteInfo = await getOrgSiteInfo(url, cookies);
|
|
const orgSiteInfoMs = Math.round((performance.now() - orgSiteInfoStart) * 100) / 100;
|
|
|
|
const response: LoadOutput = {
|
|
orgSiteName: orgSiteInfo.orgSiteName,
|
|
isOrgSite: orgSiteInfo.isOrgSite,
|
|
skipAuth: orgSiteInfo.subdomain === 'play' || debugPlay === 'true',
|
|
org: orgSiteInfo.org,
|
|
baseMetaTags: getBaseMetaTags(url, orgSiteInfo),
|
|
serverLang: request.headers?.get('accept-language') || '',
|
|
localeCookie: cookies.get('classroomio_locale') || '',
|
|
locals,
|
|
uploadLimits: getUploadLimits()
|
|
};
|
|
|
|
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}`
|
|
);
|
|
|
|
// If it isn't a registered dashboard domain and also not a valid sub domain.
|
|
// if (!APP_SUBDOMAINS.includes(orgSiteInfo.subdomain) && !dev && !orgSiteInfo.isOrgSite) {
|
|
// redirect(307, 'https://app.classroomio.com');
|
|
// }
|
|
|
|
return response;
|
|
};
|