Next.js Discord

Discord Forum

Revalidate config for route handler

Unanswered
Flemish Giant posted this in #help-forum
Open in Discord
Flemish GiantOP
In NextJS 15, I've exported a revalidate config for a route handler, and I wanna get the params from the route handler url using request.nextUrl.searchParams, but it failed to cache within the revalidate time, someone knows how to solve this?
import { NextRequest, NextResponse } from "next/server";

export const dynamic = 'force-static'
export const revalidate = 10

export async function GET(request: NextRequest) {
    const test = request.nextUrl.searchParams.get('test');
    console.log(test);
    return NextResponse.json({ message: `${new Date().toLocaleTimeString()}` });
}

0 Replies