@accelerated-software-development/caddy-api-client - v0.2.2
    Preparing search index...

    Function buildMitmproxyRoutePair

    • Create a hot-swappable route pair for enabling/disabling MITMproxy interception

      Returns both a direct route and a MITMproxy-intercepted route with the same ID. Use this to easily toggle between direct and intercepted traffic at runtime.

      Parameters

      • options: {
            backendHost: string;
            backendPort: number;
            host: string;
            mitmproxyHost: string;
            mitmproxyPort?: number;
            priority?: number;
            routeId: string;
        }

        Configuration for the route pair

        • backendHost: string

          Backend service host

        • backendPort: number

          Backend service port

        • host: string

          Host pattern to match

        • mitmproxyHost: string

          MITMproxy host

        • OptionalmitmproxyPort?: number

          MITMproxy proxy port (default: 8080)

        • Optionalpriority?: number

          Route priority (optional)

        • routeId: string

          Route ID (used for both routes)

      Returns { direct: CaddyRoute; proxied: CaddyRoute }

      Object with direct and proxied route configurations

      • direct: CaddyRoute

        Direct route (Client → Caddy → Backend)

      • proxied: CaddyRoute

        Proxied route (Client → Caddy → MITMproxy → Backend)

      const routes = buildMitmproxyRoutePair({
      host: "api.example.com",
      backendHost: "backend-service",
      backendPort: 3000,
      mitmproxyHost: "mitmproxy",
      routeId: "api_route",
      });

      // Start with direct routing
      await client.addRoute("https_server", routes.direct, routes.direct["@id"]);

      // Hot-swap to enable interception (no downtime)
      await client.removeRouteById("https_server", routes.direct["@id"]);
      await client.addRoute("https_server", routes.proxied, routes.proxied["@id"]);

      // Hot-swap back to direct (disable interception)
      await client.removeRouteById("https_server", routes.proxied["@id"]);
      await client.addRoute("https_server", routes.direct, routes.direct["@id"]);