Files
loki df654fcb92
CI / backend-tests (push) Successful in 9s
Docker images / version (push) Successful in 1s
CI / docker (push) Successful in 21s
Docker images / backend (push) Successful in 5s
Docker images / frontend (push) Successful in 6s
fix: api-proxy per middleware (laufzeit-env statt build-time rewrites)
2026-10-04 13:52:18 +02:00

16 lines
589 B
TypeScript

import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
// Proxies /api/* to the backend. Runs per request, so BACKEND_URL is read
// at RUNTIME (unlike next.config.js rewrites, which are baked at build time
// in standalone mode and ignore container env vars).
export function middleware(req: NextRequest) {
const backend = process.env.BACKEND_URL || "http://127.0.0.1:8000";
const target = new URL(req.nextUrl.pathname + req.nextUrl.search, backend);
return NextResponse.rewrite(target);
}
export const config = {
matcher: "/api/:path*",
};