File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
apps/docs/app/api/revalidate Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -47,8 +47,11 @@ export async function _handleRevalidateRequest(request: NextRequest) {
4747 return new Response ( 'Invalid Authorization header' , { status : 401 } )
4848 }
4949
50- const result = requestBodySchema . safeParse ( await request . json ( ) )
51- if ( ! result . success ) {
50+ let result : z . infer < typeof requestBodySchema >
51+ try {
52+ result = requestBodySchema . parse ( await request . json ( ) )
53+ } catch ( error ) {
54+ console . error ( error )
5255 return new Response (
5356 'Malformed request body: should be a JSON object with a "tags" array of strings.' ,
5457 { status : 400 }
@@ -64,7 +67,7 @@ export async function _handleRevalidateRequest(request: NextRequest) {
6467 const { data : lastRevalidation , error } = await supabaseAdmin . rpc (
6568 'get_last_revalidation_for_tags' ,
6669 {
67- tags : result . data . tags ,
70+ tags : result . tags ,
6871 }
6972 )
7073 if ( error ) {
@@ -86,12 +89,12 @@ export async function _handleRevalidateRequest(request: NextRequest) {
8689
8790 const { error } = await supabaseAdmin
8891 . from ( 'validation_history' )
89- . insert ( result . data . tags . map ( ( tag ) => ( { tag } ) ) )
92+ . insert ( result . tags . map ( ( tag ) => ( { tag } ) ) )
9093 if ( error ) {
9194 console . error ( 'Failed to update revalidation table: %o' , error )
9295 }
9396
94- result . data . tags . forEach ( ( tag ) => {
97+ result . tags . forEach ( ( tag ) => {
9598 revalidateTag ( tag )
9699 } )
97100
You can’t perform that action at this time.
0 commit comments