mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 05:05:38 -04:00
Introduce a local disk cache for TMDB images served through a proxy API route (/api/images/[...path]), eliminating direct client-side CDN dependencies. Images are cached by category (posters, backdrops, stills, logos) and served with immutable cache headers. Move all tmdbImageUrl() calls from client components to API routes and server components so clients receive ready-to-use URLs. This removes the need to expose TMDB_IMAGE_BASE_URL and IMAGE_CACHE_ENABLED via next.config.ts env block. The landing page is split into a server wrapper (app/page.tsx) and client component (components/landing-page.tsx). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { headers } from "next/headers";
|
|
import { NextResponse } from "next/server";
|
|
import { auth } from "@/lib/auth/server";
|
|
import { getContinueWatchingFeed } from "@/lib/services/discovery";
|
|
import { tmdbImageUrl } from "@/lib/tmdb/image";
|
|
|
|
export async function GET() {
|
|
const session = await auth.api.getSession({
|
|
headers: await headers(),
|
|
});
|
|
if (!session)
|
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
|
|
const feed = await getContinueWatchingFeed(session.user.id);
|
|
return NextResponse.json(
|
|
feed.map((item) => ({
|
|
...item,
|
|
title: {
|
|
...item.title,
|
|
posterPath: tmdbImageUrl(item.title.posterPath, "w500"),
|
|
backdropPath: tmdbImageUrl(item.title.backdropPath, "w1280"),
|
|
},
|
|
nextEpisode: item.nextEpisode
|
|
? {
|
|
...item.nextEpisode,
|
|
stillPath: tmdbImageUrl(
|
|
item.nextEpisode.stillPath,
|
|
"w1280",
|
|
"stills",
|
|
),
|
|
}
|
|
: null,
|
|
})),
|
|
);
|
|
}
|