import type { CapacitorConfig } from "@capacitor/cli";

const config: CapacitorConfig = {
  appId: "com.nadi.player",
  appName: "Nadiplayer",
  webDir: "dist",
  // Allow HTTP (cleartext) traffic for IPTV/Xtream servers that don't use HTTPS.
  android: {
    allowMixedContent: true,
  },
  server: {
    // Load the bundled web assets on device (default).
    // For live debugging against a dev server, uncomment and set your LAN URL:
    // url: "http://192.168.1.10:3000",
    androidScheme: "https",
    cleartext: true,
  },
  plugins: {
    // Use native HTTP client for fetch/XHR. This bypasses the WebView's
    // CORS layer (which on Capacitor Android with `androidScheme: "https"`
    // sets the origin to `https://localhost` and triggers strict CORS
    // checks against external APIs like https://4kmovies.vip/nadiplayer).
    // With CapacitorHttp enabled, fetch() goes through Android's native
    // OkHttp/HttpURLConnection — no CORS preflight, full status codes &
    // bodies preserved, cookies handled natively. This is the canonical
    // fix for "empty response from server" on installed Android APKs.
    CapacitorHttp: {
      enabled: true,
    },
  },
};

export default config;
