fix: replace Directus SDK with native fetch for featured content

Replace customEndpoint() with native fetch in getFeaturedModels() and
getFeaturedVideos() to return plain JSON instead of non-serializable
Directus SDK objects. This resolves the SvelteKit serialization error:
"Cannot stringify arbitrary non-POJOs".

Changes:
- Use native fetch with PUBLIC_URL instead of getDirectusInstance()
- Return plain JSON via response.json() instead of SDK request objects
- Remove JSON.parse(JSON.stringify()) serialization hack from +page.server.ts
- Rename fetch parameter to fetchFn for clarity

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Valknar XXX
2025-10-28 23:54:56 +01:00
parent 10ab7a65df
commit 0b07da8e64
2 changed files with 16 additions and 24 deletions

View File

@@ -1,13 +1,7 @@
import { getFeaturedModels, getFeaturedVideos } from "$lib/services";
export async function load({ fetch }) {
const [models, videos] = await Promise.all([
getFeaturedModels(3, fetch),
getFeaturedVideos(3, fetch),
]);
// Ensure data is serializable by converting to plain JSON
return {
models: JSON.parse(JSON.stringify(models)),
videos: JSON.parse(JSON.stringify(videos)),
models: await getFeaturedModels(3, fetch),
videos: await getFeaturedVideos(3, fetch),
};
}