mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-22 12:06:42 +02:00
Move inactive projects out of active workspace: - bauntown (community website) - maerchenzauber (AI story generation) - memoro (voice memo app) - news (news aggregation) - nutriphi (nutrition tracking) - reader (reading app) - uload (URL shortener) - wisekeep (AI wisdom extraction) Update CLAUDE.md documentation: - Add presi to active projects - Document archived projects section - Update workspace configuration Archived apps can be re-activated by moving back to apps/ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { defineMiddleware } from 'astro/middleware';
|
|
import { getRedirectUrl, getRedirectStatus } from './utils/redirects';
|
|
|
|
export const onRequest = defineMiddleware(async (context, next) => {
|
|
const { url } = context;
|
|
const { pathname } = url;
|
|
|
|
// 1. Prüfe zuerst die Redirect-Map für alte URLs
|
|
const redirectUrl = getRedirectUrl(pathname);
|
|
if (redirectUrl) {
|
|
const status = getRedirectStatus(pathname);
|
|
return context.redirect(redirectUrl, status);
|
|
}
|
|
|
|
// 2. Handle root path - redirect to /de
|
|
if (pathname === '/') {
|
|
return context.redirect('/de', 301);
|
|
}
|
|
|
|
// 3. Handle paths without language prefix (except special paths)
|
|
const segments = pathname.split('/').filter(Boolean);
|
|
const firstSegment = segments[0];
|
|
const validLanguages = ['de', 'en'];
|
|
const specialPaths = ['admin', 'api', '_astro', 'images', 'favicon', '404'];
|
|
|
|
// If no language prefix and not a special path, redirect to /de/...
|
|
if (
|
|
!validLanguages.includes(firstSegment) &&
|
|
!specialPaths.includes(firstSegment) &&
|
|
!pathname.includes('.')
|
|
) {
|
|
return context.redirect(`/de${pathname}`, 301);
|
|
}
|
|
|
|
// 4. Lasse alle anderen Requests durch
|
|
const response = await next();
|
|
|
|
// 5. Log 404 errors für Monitoring (nur in Production)
|
|
if (response.status === 404 && import.meta.env.PROD) {
|
|
console.warn(
|
|
`404 Error: ${pathname} | Referrer: ${context.request.headers.get('referer') || 'direct'}`
|
|
);
|
|
}
|
|
|
|
return response;
|
|
});
|