fix(server/proxy): ajout duplex half pour forwarder les POST

- Route proxy: ajout de duplex: 'half' lors de l'envoi d'un body,
  requis par Node.js fetch pour éviter l'erreur 500 sur wp-login.php
This commit is contained in:
EduBox Dev
2026-06-17 18:55:50 +00:00
parent 5cb70cd307
commit a94b7526f7
+4 -4
View File
@@ -42,13 +42,13 @@ async function proxyRequest(req: NextRequest) {
headers.set("x-forwarded-port", "443"); headers.set("x-forwarded-port", "443");
headers.set("x-forwarded-for", req.headers.get("x-forwarded-for") || "unknown"); headers.set("x-forwarded-for", req.headers.get("x-forwarded-for") || "unknown");
const needsBody = req.method !== "GET" && req.method !== "HEAD";
const upstreamRes = await fetch(upstream, { const upstreamRes = await fetch(upstream, {
method: req.method, method: req.method,
headers, headers,
body: body: needsBody ? (req.body as BodyInit) : undefined,
req.method !== "GET" && req.method !== "HEAD" // Node.js fetch requires duplex when forwarding a request body stream
? (req.body as BodyInit) ...(needsBody ? { duplex: "half" } : {}),
: undefined,
redirect: "manual", redirect: "manual",
}); });