Files
edubox/server/middleware.ts
T
EduBox Dev b383b11ae2 feat(agent,server): v0.2.7 - mu-plugin WordPress robuste, réparation wp-config, proxy cookies/headers
- Agent: mu-plugin embarqué amélioré (HTTPS forcé, filtres URL, localhost:port)
- Agent: suppression des WP_HOME/WP_SITEURL hardcodés au démarrage des instances
- Server/proxy: envoi X-Forwarded-Port, réécriture headers/body élargie
- Server/proxy: sanitization des Set-Cookie (Secure, SameSite, Domain)
- Dashboard: version agent 0.2.7, action Supprimer complète
- Cleanup: binaires agent 0.2.3-0.2.6 remplacés par 0.2.7
2026-06-17 18:23:06 +00:00

29 lines
865 B
TypeScript

import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
const MAIN_DOMAIN = process.env.MAIN_DOMAIN || "alfrednobel.edudeploy.com";
export function middleware(req: NextRequest) {
const host = req.headers.get("host") || "";
const cleanHost = host.split(":")[0];
if (cleanHost === MAIN_DOMAIN || cleanHost === `www.${MAIN_DOMAIN}`) {
return NextResponse.next();
}
if (!cleanHost.endsWith(`.${MAIN_DOMAIN}`)) {
return NextResponse.next();
}
const pathname = req.nextUrl.pathname;
const search = req.nextUrl.search;
// Rewrite to the internal proxy API while preserving the original host header
const rewriteUrl = new URL(`/api/proxy${pathname}${search}`, req.url);
return NextResponse.rewrite(rewriteUrl);
}
export const config = {
matcher: ["/((?!api/proxy|_next|static|favicon.ico).*)"],
};