Strapi plus Next App Router, where does the Croct proxy go and how do I keep my own middleware?
My Strapi-backed site runs on the Next App Router and I already have custom middleware for auth. I followed an older tutorial that mentioned a Croct middleware export I could not find it anywhere in the current package, and now I am not sure how the setup works or how to avoid clobbering the middleware I already have.
1 answer
The export was renamed. What older tutorials call middleware is now the proxy:
export {proxy} from '@croct/plug-next/proxy';
export const config = { matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],};The matcher excludes paths like api, _next/static and similar so the proxy only runs where it should. Since you already have auth middleware, do not add a second middleware file. Compose them in your existing one with the withCroct wrapper so both run in order. On the client side the App Router provider is @croct/plug-next/CroctProvider, which is env-driven through NEXT_PUBLIC_CROCT_APP_ID and CROCT_API_KEY and takes no appId prop, and server content is read with fetchContent from @croct/plug-next/server.
See the proxy export and matcher and composing with withCroct.