Made infrastructure to ensure private data is not leaked to client
This commit is contained in:
@@ -1,20 +1,12 @@
|
||||
import { dev } from '$app/environment';
|
||||
import { config, type Config } from '$lib/config';
|
||||
import { clientConfig, type Config } from '$lib/config';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
import { readFileSync } from 'fs';
|
||||
import * as yml from 'js-yaml';
|
||||
|
||||
export const load: PageServerLoad = () => {
|
||||
export const load: PageServerLoad = ({locals}) => {
|
||||
if (dev) {
|
||||
return { config: config };
|
||||
return { config: clientConfig };
|
||||
}
|
||||
|
||||
try {
|
||||
const dynamic = yml.load(readFileSync('/dynamic/config.yml', 'utf8'));
|
||||
return { config: { ...config, ...dynamic } as Config };
|
||||
} catch (err) {
|
||||
console.debug("could not read '/dynamic/config.yml': " + err);
|
||||
return { config: config };
|
||||
}
|
||||
return {config: (locals as Record<string,Config>).config || clientConfig};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user