Pfad-Problem behoben. Hoffe ich...
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 9s

This commit is contained in:
2026-03-31 12:41:13 +02:00
parent a44d1363cd
commit df6a0fa504
3 changed files with 21 additions and 4 deletions

18
src/utils/paths.ts Normal file
View File

@@ -0,0 +1,18 @@
// src/utils/paths.ts
// Wir greifen auf die Umgebungsvariable von Astro zu
const base = import.meta.env.BASE_URL;
/**
* Erstellt einen korrekten Pfad unter Berücksichtigung der Astro 'base' Konfiguration.
* Verhindert doppelte Slashes und funktioniert in Dev, Test und Prod.
*/
export function getPath(path: string): string {
// Entfernt den Slash am Ende der Base, falls vorhanden
const normalizedBase = base.replace(/\/$/, '');
// Stellt sicher, dass der Pfad mit einem Slash beginnt
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
return `${normalizedBase}${normalizedPath}`;
}