Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(proxy): bypass next-intl for RSC and server-action requests (#475)

Gökhan Geyik847cc43e9dda
diff --git a/web/src/proxy.ts b/web/src/proxy.ts
index 5f756f01f..fbaf5f190 100644
--- a/web/src/proxy.ts
+++ b/web/src/proxy.ts
@@ -55,6 +55,30 @@ export async function proxy(request: NextRequest) {
return NextResponse.redirect(new URL('/dashboard', request.url));
}
+ // Workaround for a Next.js framework issue (vercel/next.js#91723): RSC
+ // prefetch/navigation requests and server-action POSTs that go through
+ // next-intl's middleware intermittently die server-side with "The router
+ // state header was sent but could not be parsed" — and the client then
+ // holds its whole server-action queue behind the failed transition, which
+ // froze the Prompts page. With a single 'en' locale the only thing the
+ // intl middleware does for these requests is the /en rewrite, so do that
+ // by hand and skip the intl machinery entirely.
+ const isRscOrAction = request.headers.has('rsc') || request.headers.has('next-action');
+ if (isRscOrAction) {
+ const needsLocalePrefix = !(pathname === '/en' || pathname.startsWith('/en/'));
+ const response = needsLocalePrefix
+ ? NextResponse.rewrite(new URL(`/en${pathname}${request.nextUrl.search}`, request.url), {
+ request,
+ })
+ : NextResponse.next({ request });
+ if (supabaseResponse) {
+ supabaseResponse.cookies.getAll().forEach((cookie) => {
+ response.cookies.set(cookie.name, cookie.value, cookie);
+ });
+ }
+ return response;
+ }
+
const intlResponse = intlMiddleware(request);
if (supabaseResponse) {