Merge pull request #5 from Salastil/claude/source-management-content-1w2yno
Claude/source management content 1w2yno
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
import { env } from '$env/dynamic/private';
|
||||
import type { LayoutServerLoad } from './$types';
|
||||
|
||||
// The admin panel is off by default on every deployment — it only appears (cog icon
|
||||
// and the /admin/* pages themselves, see admin/+layout.svelte) once this is
|
||||
// explicitly turned on. This is a UI-visibility gate only; the backend's API key
|
||||
// check on every /api/admin/* request is what actually protects it either way.
|
||||
//
|
||||
// Uses $env/dynamic/private rather than raw process.env — Vite does not inject
|
||||
// arbitrary (non-VITE_-prefixed) .env vars into process.env for server code, so
|
||||
// process.env.ADMIN_PANEL_ENABLED is always undefined here even with it set in
|
||||
// frontend/.env. $env/dynamic/private is SvelteKit's own env accessor and reads it
|
||||
// correctly in dev, preview, and any adapter-based deployment.
|
||||
export const load: LayoutServerLoad = async () => {
|
||||
return { adminPanelEnabled: process.env.ADMIN_PANEL_ENABLED === 'true' };
|
||||
return { adminPanelEnabled: env.ADMIN_PANEL_ENABLED === 'true' };
|
||||
};
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<!-- Never actually renders — +page.ts's load always redirects to /admin/settings before this displays. -->
|
||||
@@ -0,0 +1,9 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
// There's no page at exactly /admin — only /admin/login and /admin/settings — so a
|
||||
// bare visit here would otherwise 404. Settings itself already redirects to login on
|
||||
// a 401, so sending everyone through there is the one sensible default landing spot.
|
||||
export const load: PageLoad = async () => {
|
||||
throw redirect(302, '/admin/settings');
|
||||
};
|
||||
Reference in New Issue
Block a user