add route matcher to fix /login and /logout routes
Some checks failed
CI / update (push) Failing after 2m52s
Some checks failed
CI / update (push) Failing after 2m52s
Use SvelteKit param matcher to constrain [recipeLang] to only match 'recipes' or 'rezepte', preventing it from catching /login, /logout, and other non-recipe routes.
This commit is contained in:
17
src/routes/[recipeLang=recipeLang]/+layout.server.ts
Normal file
17
src/routes/[recipeLang=recipeLang]/+layout.server.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { LayoutServerLoad } from "./$types"
|
||||
import { error } from "@sveltejs/kit";
|
||||
|
||||
export const load : LayoutServerLoad = async ({locals, params}) => {
|
||||
// Validate recipeLang parameter
|
||||
if (params.recipeLang !== 'rezepte' && params.recipeLang !== 'recipes') {
|
||||
throw error(404, 'Not found');
|
||||
}
|
||||
|
||||
const lang = params.recipeLang === 'recipes' ? 'en' : 'de';
|
||||
|
||||
return {
|
||||
session: await locals.auth(),
|
||||
lang,
|
||||
recipeLang: params.recipeLang
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user