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) {
|
||||
|
||||
Reference in New Issue
Block a user