feat: proxy cache

This commit is contained in:
ner committed 2024-11-03 17:42:40 +02:00
1 parent 32e7885791
commit 995342f18a
9 files changed
+17 -28

No files matched your search

-11
View File
@@ -1,11 +0,0 @@
import { Loader } from 'lucide-react';
const Loading = () => (
<div className='flex min-h-[70vh] w-full items-center justify-center'>
<div className='animate-spin'>
<Loader />
</div>
</div>
);
export default Loading;
+2 -2
View File
@@ -5,12 +5,12 @@ import getQueryClient from '@/lib/queryClient';
import Container from './container';
const Random = async () => {
const Random = () => {
const queryClient = getQueryClient();
const page = generatePage();
await queryClient.prefetchInfiniteQuery(randomQuery({ page, suspense: false }));
queryClient.prefetchInfiniteQuery(randomQuery({ page }));
return (
<HydrationBoundary state={dehydrate(queryClient)}>
+5 -3
View File
@@ -8,13 +8,15 @@ type TMDBParams = {
};
};
export async function GET({ nextUrl: { searchParams }, headers }: NextRequest, { params: { path } }: TMDBParams) {
export async function GET({ nextUrl: { searchParams } }: NextRequest, { params: { path } }: TMDBParams) {
try {
const response = await fetch(`${MOVIE_DB_API_URL}/${path.join('/')}?${searchParams.toString()}`, {
const params = searchParams.toString();
const response = await fetch(`${MOVIE_DB_API_URL}/${path.join('/')}${params ? `?${params}` : ''}`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${MOVIE_DB_TOKEN}`
}
},
next: searchParams.get('session_id') ? undefined : { revalidate: 3600 }
});
if (!response.ok) {