Files
nodeMap/pages/api/[...path].js
Ismail Ali b097a76d34 docs+refactor: Proxy [...path].js auf dynamische Ziel-URL umgestellt (v1.1.77)
- entfernt: NEXT_PUBLIC_SERVER_URL aus .env.local
- verwendet jetzt API_PORT_MODE zur Zielermittlung (dev = :80)
- neue technische Dokumentation unter /docs/server/pages/api/apiProxy.md
- CHANGELOG.md und appVersion.js aktualisiert (1.1.77)
2025-05-17 01:10:18 +02:00

16 lines
457 B
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// pages/api/[...path].js
import { createProxyMiddleware } from "http-proxy-middleware";
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
const target = mode === "dev" ? "http://localhost:80" : "http://localhost"; // oder z.B. http://10.10.0.13
export default createProxyMiddleware({
target,
changeOrigin: true,
pathRewrite: {
"^/api": "/", // Entfernt /api aus dem Pfad, wenn das Backend das nicht erwartet
},
logLevel: "debug",
});