Skip to content

Middleware not redirecting server function invocations #81608

Closed Answered by gmoniava
gmoniava asked this question in App Router
Discussion options

You must be logged in to vote

It seems answer is this (from the gh link I mentioned):

export const config = {
  matcher: [
    /*
     * Match all request paths except for the ones starting with:
     * - api (API routes)
     * - _next/static (static files)
     * - _next/image (image optimization files)
     * - favicon.ico (favicon file)
     */
    {
      source:
        '/((?!api|_next/static|_next/image|media|fonts|favicon.ico|favicon.png).*)',
      missing: [
        // Exclude Server Actions
        { type: 'header', key: 'next-action' },
      ],
    },
  ],
};

Somehow I thought initially it was using "api" check to exclude server functions from middleware but I was wrong.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gmoniava
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant