revert: undo adminPath routing attempts — clean slate for restart

This commit is contained in:
Falkan
2026-03-17 20:39:51 -04:00
parent 3a256ccef5
commit 51f047df3e
6 changed files with 1 additions and 72 deletions

Binary file not shown.

View File

@@ -71,22 +71,6 @@
"symbol": "mfcktn", "symbol": "mfcktn",
"group": "dickloads", "group": "dickloads",
"toBase": 170.2399999998 "toBase": 170.2399999998
},
{
"id": "shitload",
"label": "Shitload",
"labelPlural": "Shitloads",
"symbol": "shtld",
"group": "dickloads",
"toBase": 12.6666666667
},
{
"id": "shit-ton",
"label": "Shit ton",
"labelPlural": "Shit tons",
"symbol": "shttn",
"group": "dickloads",
"toBase": 25.3333333333
} }
], ],
"groups": [ "groups": [

View File

@@ -1,10 +0,0 @@
import { loadConfig } from '$lib/server/data';
import type { Handle } from '@sveltejs/kit';
/**
* handle: no URL rewriting here (that's reroute in hooks.ts).
* Kept as a placeholder for future server-only middleware.
*/
export const handle: Handle = async ({ event, resolve }) => {
return resolve(event);
};

View File

@@ -1,40 +0,0 @@
import type { Reroute } from '@sveltejs/kit';
/**
* reroute: rewrites the configured adminPath to the internal /admin route.
* Reads config.json directly (not via $lib/server/data) so this universal
* hook can run server-side without triggering the browser-import guard.
*
* Example: adminPath = "boss"
* /boss → /admin
* /boss/login → /admin/login
* /boss/api/... → /admin/api/...
*/
export const reroute: Reroute = ({ url }) => {
// Only runs on the server — typeof window is undefined here during SSR/Node.
// In the browser, SvelteKit client-side routing never calls reroute for
// server routes, so this branch is safe to guard.
if (typeof window !== 'undefined') return url.pathname;
try {
// Dynamic require so bundler doesn't try to resolve at build time
// eslint-disable-next-line @typescript-eslint/no-require-imports
const fs = require('fs') as typeof import('fs');
// eslint-disable-next-line @typescript-eslint/no-require-imports
const path = require('path') as typeof import('path');
const configPath = path.resolve('data', 'config.json');
const config = JSON.parse(fs.readFileSync(configPath, 'utf8')) as { adminPath?: string };
const adminPath = (config.adminPath ?? 'admin').replace(/^\/|\/$/g, '');
if (adminPath === 'admin') return url.pathname;
const prefix = `/${adminPath}`;
if (url.pathname === prefix || url.pathname.startsWith(prefix + '/')) {
return '/admin' + url.pathname.slice(prefix.length);
}
} catch {
// If config can't be read, fall through to default routing
}
return url.pathname;
};

View File

@@ -1,6 +1,5 @@
import { redirect } from '@sveltejs/kit'; import { redirect } from '@sveltejs/kit';
import { authRequest } from '$lib/server/auth'; import { authRequest } from '$lib/server/auth';
import { loadConfig } from '$lib/server/data';
import type { LayoutServerLoad } from './$types'; import type { LayoutServerLoad } from './$types';
export const load: LayoutServerLoad = ({ request, url }) => { export const load: LayoutServerLoad = ({ request, url }) => {
@@ -15,9 +14,7 @@ export const load: LayoutServerLoad = ({ request, url }) => {
} }
if (!authRequest(request)) { if (!authRequest(request)) {
// Redirect to login using the configured admin path so the URL stays consistent throw redirect(302, '/admin/login');
const adminPath = (loadConfig().adminPath ?? 'admin').replace(/^\/|\/$/g, '');
throw redirect(302, `/${adminPath}/login`);
} }
return { authenticated: true }; return { authenticated: true };

View File

@@ -771,8 +771,6 @@
> >
<span <span
class="drag-handle" class="drag-handle"
role="button"
tabindex="0"
draggable="true" draggable="true"
ondragstart={(e) => onUnitDragStart(e, unit.id, null)} ondragstart={(e) => onUnitDragStart(e, unit.id, null)}
ondragend={onUnitDragEnd} ondragend={onUnitDragEnd}