fix(cms): adjust caching behavior for development environment
- Modified cached function to bypass caching in development mode. - Updated fetchOpenApi function to return cached data only if not in development mode, ensuring accurate API fetching during development.
This commit is contained in:
+2
-1
@@ -77,6 +77,7 @@ async function cached<T>(
|
||||
key: string,
|
||||
fn: () => Promise<T>,
|
||||
): Promise<T> {
|
||||
if (import.meta.env.DEV) return fn();
|
||||
const hit = cache.get(key);
|
||||
if (hit && hit.expires > Date.now()) return hit.value as T;
|
||||
const pending = inflight.get(key) as Promise<T> | undefined;
|
||||
@@ -122,7 +123,7 @@ export function cacheStats(): { size: number; keys: string[] } {
|
||||
* Wird gecacht (einmal pro Request/Build).
|
||||
*/
|
||||
export async function fetchOpenApi(): Promise<OpenApiSpec> {
|
||||
if (openApiCache) return openApiCache;
|
||||
if (openApiCache && !import.meta.env.DEV) return openApiCache;
|
||||
const base = getBaseUrl();
|
||||
const res = await fetch(`${base}/api-docs/openapi.json`);
|
||||
if (!res.ok) {
|
||||
|
||||
@@ -96,6 +96,7 @@
|
||||
<div class="flex items-center justify-between container-custom py-2">
|
||||
<a
|
||||
href="/"
|
||||
aria-label={t(T.site_name_fallback)}
|
||||
class="logo flex items-center origin-left font-bold text-lg tracking-wide hover:scale-[1.12] transition-transform duration-200 ease-out relative"
|
||||
>
|
||||
{#if logoSvgHtml}
|
||||
@@ -178,9 +179,10 @@
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-2 -mr-2 hover:bg-stein-0/10 rounded-md transition-colors aria-expanded={menuOpen} flex items-center justify-center"
|
||||
class="p-2 -mr-2 hover:bg-stein-0/10 rounded-md transition-colors flex items-center justify-center"
|
||||
aria-label={menuOpen ? t(T.header_menu_close) : t(T.header_menu_open)}
|
||||
aria-controls="mobile-nav"
|
||||
aria-controls={menuOpen ? "mobile-nav" : undefined}
|
||||
aria-expanded={menuOpen}
|
||||
onclick={toggleMenu}
|
||||
>
|
||||
<span class="sr-only"
|
||||
|
||||
Reference in New Issue
Block a user