Skip to content
Discussion options

You must be logged in to vote

Hmm, that looks a bit odd indeed. Can you share how many middleware invocations you have?

Based on my local tests with the App Router example, the middleware invocation takes a few ms (typically between 4-8ms).

Let's say we take 8ms as an example and 2h 1m of compute time, that would account for 907,500 invocations!

Is your middleware potentially called on unrelated routes? One thing to be aware of is that Next.js prefetches pages for all links on a page. So if you render a page and it has links to 100 pages, then you don't get 1 middleware invocation per "visit", but 101.

To address your question from above, localePrefix: 'as-needed' indeed requires middleware invocations—at least for yo…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@amannn
Comment options

@jgcjordi
Comment options

Answer selected by jgcjordi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants