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

const config: CapacitorConfig = {
  appId: 'com.billtracker.app',
  appName: 'Bill Tracker',
  webDir: 'dist',
  android: {
    // Allow HTTP (cleartext) for local network servers
    allowMixedContent: true,
  },
  server: {
    // androidScheme must be https for cookies to work correctly
    androidScheme: 'https',
    // In local mode, the WebView navigates to the embedded Node server on
    // 127.0.0.1 — without this it's treated as an external link and opened
    // in the system browser instead of the app's WebView.
    allowNavigation: ['127.0.0.1'],
  },
  plugins: {
    CapacitorHttp: {
      // Routes fetch()/XHR through native HTTP so the server-mode login
      // request isn't blocked by CORS, and the resulting session cookie is
      // written to the WebView's cookie store for the subsequent WebView
      // navigation to the server URL.
      enabled: true,
    },
  },
};

export default config;
