# Should the Croct proxy matcher exclude _next/static and image routes?

Asked by elifyz on 2026-04-08. Tags: nextjs, middleware, performance.

I copied a minimal middleware file from an example while wiring up
`@croct/plug-next` and only later noticed it had no `config.matcher` at all.
Which means the Croct proxy is currently running on literally every request,
including fonts, images and everything under `_next/static`.

Two questions:

1. Does that actually hurt performance, or is the proxy cheap enough that it
   does not matter?
2. What does the recommended matcher look like? I have seen a few variations
   and I want the one the docs intend.

The site is fine so far but we get a decent amount of traffic and I would
rather fix this before it becomes a mystery later

## 2 answers

### Accepted answer from Rob Ferreira (2026-04-08)

Yes, add the matcher. The documented setup ships with one for exactly this
reason:

```ts
export const config = {
    matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
};
```

The proxy exists to handle tokens and request context for page rendering.
A request for a font file or a static chunk has no page to personalize, so
running the proxy there adds latency and middleware invocations for zero
value. It will not break anything, it is just pure waste.

On whether it "hurts": each asset request pays the middleware cost, and on a
typical page that is dozens of requests. If you are on a platform that bills
per middleware invocation you are also paying for it directly. So not a fire,
but definitely fix it.

### Answer from annakhl (2026-04-09)

One thing I would add from experience: if you have other route groups that
never render Croct content (webhook endpoints, health checks, a status page),
you can extend the negative lookahead to skip those too. The pattern in the
docs is the baseline, not a ceiling. Just be careful not to exclude actual
page routes or the SDK will complain about the missing proxy on those pages.
