File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 1+ import { revalidatePath } from 'next/cache' ;
2+ import type { NextRequest } from 'next/server' ;
3+
4+ export async function GET ( request : NextRequest ) {
5+ const path = request . nextUrl . searchParams . get ( 'path' ) ;
6+
7+ if ( path ) {
8+ revalidatePath ( path ) ;
9+ return Response . json ( { revalidated : true , now : Date . now ( ) } ) ;
10+ }
11+
12+ return Response . json ( {
13+ revalidated : false ,
14+ now : Date . now ( ) ,
15+ message : 'Missing path to revalidate' ,
16+ } ) ;
17+ }
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ export const FetchUserButton: FC<FetchUserButtonProps> = ({
8080 fetchAttempt . current += 1 ;
8181 setLoadingLabel ( FETCH_MESSAGES [ fetchAttempt . current % FETCH_MESSAGES . length ] ) ;
8282 } else {
83+ await fetch ( `/api/revalidate?path=${ encodeURIComponent ( `/profile/${ login } ` ) } ` ) ;
8384 window . location . reload ( ) ;
8485 }
8586 } , [ login ] ) ;
Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ import { TopRanksDocument } from '@/types/generated/graphql';
77type ProfileLayoutProps = Readonly < { children : React . ReactNode ; params : Promise < { login : string } > } > ;
88
99// Next.js will invalidate the cache when a
10- // request comes in, at most once every 10800 seconds .
11- export const revalidate = 10800 ;
10+ // request comes in, at most once every 3 hours .
11+ export const revalidate = 10800 ; // 3 hours
1212
1313// We'll prerender only the params from `generateStaticParams` at build time.
1414// If a request comes in for a path that hasn't been generated,
You can’t perform that action at this time.
0 commit comments