#I can't response into a server action from middleware

7 messages · Page 1 of 1 (latest)

wheat grove
#
export async function middleware(request: NextRequest) {
    const NEXT_ACTION = headers().get("next-action")

    if (NEXT_ACTION === ContactActions.Mail) {
        console.log("Is mail servera ction")
        return NextResponse.json({
            status: "error",
            message: "You have reached the limit"
        }, { status: 429 })
    }
}

export const config = {
    matcher: '/:path*',
}

I'm trying to do some kind of ratelimiting but I coudn't respond to server actions from middleware to access it in the form and getting undefined

civic condorBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

paper briar
wheat grove
#

My problem is I can't overwrite the response of the server action

#

I want the server action to respond with rate limit response instead of responding with it's normal response

paper briar