fix(prod): resolve middleware piping error and AI model ID
Some checks failed
Build & Deploy / 🧪 QA (push) Failing after 1m44s
Build & Deploy / 🔍 Prepare (push) Successful in 16s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 3s

This commit is contained in:
2026-04-09 11:33:35 +02:00
parent 1ad12a9818
commit 49f5c67aa2
2 changed files with 33 additions and 6 deletions

View File

@@ -51,12 +51,26 @@ export default async function middleware(request: NextRequest) {
const hostHeader = headers.get('x-forwarded-host') || headers.get('host') || fallbackHost;
urlObj.protocol = proto;
effectiveRequest = new NextRequest(urlObj, {
headers: request.headers,
method: request.method,
body: request.body,
});
// Do NOT reconstruct NextRequest for GET/HEAD requests to avoid stream locking/piping errors.
// next-intl middleware primarily uses the URL and headers, so a simplified request-like object
// or a redirected URL is often enough. For robustness, we only clone if we really have to.
if (method === 'GET' || method === 'HEAD') {
// In Next.js 15+, we can clone headers but avoid re-passing the body stream.
effectiveRequest = new NextRequest(urlObj, {
headers: new Headers(request.headers),
method: request.method,
// No body for GET/HEAD
});
} else {
// For POST/PUT etc, we must be careful. Re-passing the body can only be done once.
// If we don't need to fix the URL for the body-reading part, we can skip it.
// But usually intl-middleware doesn't care about the body.
effectiveRequest = new NextRequest(urlObj, {
headers: new Headers(request.headers),
method: request.method,
body: request.body,
});
}
if (process.env.NODE_ENV !== 'production' || !process.env.CI) {
console.log(

View File

@@ -129,3 +129,16 @@ index 9081ae77d4eae53ce660e285c1a6babde99ceaab..f262f1dd0fd1199734024cc27905d956
export const ChatWindowProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
return (
diff --git a/dist/endpoints/chatEndpoint.js b/dist/endpoints/chatEndpoint.js
--- a/dist/endpoints/chatEndpoint.js
+++ b/dist/endpoints/chatEndpoint.js
@@ -50,7 +50,7 @@
try {
const result = streamText({
// @ts-ignore - AI SDK type mismatch
- model: openrouter('google/gemini-3.0-flash'),
+ model: openrouter('google/gemini-3.1-flash-lite-preview'),
messages,
tools: activeTools,
system: `You are a helpful Payload CMS MCP Assistant orchestrating the local Mintel ecosystem.