perf(tmdb): trim responses to fields the UI uses, in proxy and server client
Move the trimmer from the route into a shared lib/tmdbTrim and apply it in the server-side client too (server hits TMDB directly, bypassing the proxy), so both paths return identical shapes. Show page HTML drops ~22% (88.4KB -> 68.8KB); TV details payload -90%.
This commit is contained in:
1 parent
88f51f783e
commit
8c8d752962
3 files changed
+95
-6
No files matched your search
@@ -2,8 +2,7 @@ import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { MOVIE_DB_API_URL, MOVIE_DB_TOKEN } from '@/env';
|
||||
import { PRIVATE_CACHE_CONTROL, PUBLIC_CACHE_CONTROL, REVALIDATE } from '@/lib/cache';
|
||||
|
||||
import trim from './trim';
|
||||
import trimTmdb from '@/lib/tmdbTrim';
|
||||
|
||||
type TMDBParams = {
|
||||
params: {
|
||||
@@ -38,7 +37,7 @@ export async function GET({ nextUrl: { searchParams } }: NextRequest, { params:
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
return NextResponse.json(trim(path.join('/'), data), {
|
||||
return NextResponse.json(trimTmdb(path.join('/'), data), {
|
||||
headers: { 'Cache-Control': isPrivate ? PRIVATE_CACHE_CONTROL : PUBLIC_CACHE_CONTROL }
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user