use axum::{ extract::State, http::{header, StatusCode}, response::{Html, IntoResponse, Response}, Json, }; use serde_json::{json, Value}; use crate::proxy::ProxyState; pub async fn get_health() -> (StatusCode, Json) { ( StatusCode::OK, Json(json!({ "status": "ok", "service": "openfut-bridge", "version": env!("CARGO_PKG_VERSION"), "note": "This proxy captures FIFA 23 traffic and routes known endpoints to OpenFUT Core." })), ) } /// Serve the TLS certificate as a downloadable PEM file. /// /// Users navigate to `https://:8443/_bridge/cert.pem` in a browser, /// download the file, and install it as a trusted CA in their OS or game console. pub async fn get_cert(State(state): State) -> Response { match &state.cert_pem { Some(pem) => ( StatusCode::OK, [ (header::CONTENT_TYPE, "application/x-pem-file"), ( header::CONTENT_DISPOSITION, "attachment; filename=\"openfut-ca.pem\"", ), ], pem.as_ref().clone(), ) .into_response(), None => ( StatusCode::NOT_FOUND, Json(json!({ "error": "TLS is not enabled; no certificate to download" })), ) .into_response(), } } /// Club management dashboard served at `/_bridge/dashboard`. /// /// Injects the Core URL so client-side JS can call Core directly without going through the proxy. pub async fn get_dashboard(State(state): State) -> Response { let template = include_str!("../dashboard.html"); let html = template.replace("{{CORE_URL}}", &state.config.core_url); Response::builder() .status(StatusCode::OK) .header(header::CONTENT_TYPE, "text/html; charset=utf-8") .body(axum::body::Body::from(html)) .unwrap() } /// HTML setup guide for connecting FIFA 23 to OpenFUT Bridge. pub async fn get_guide(State(state): State) -> Html { let host = state .config .listen_addr .split(':') .next() .unwrap_or("localhost"); let tls = state.config.tls_enabled; let scheme = if tls { "https" } else { "http" }; let port = state.config.listen_addr.split(':').next_back().unwrap_or("8080"); let bridge_url = format!("{scheme}://{host}:{port}"); let core_url = &state.config.core_url; let guide = format!( r#" OpenFUT Bridge — Setup Guide

OpenFUT Bridge — Setup Guide

Bridge is running at {bridge_url}

Core API: {core_url}

How it works

OpenFUT Bridge sits between FIFA 23 and EA's servers. It intercepts FUT API calls and routes supported endpoints to OpenFUT Core (your local offline backend). Unsupported endpoints return placeholder responses so the game stays stable.

Step 1 — Redirect FIFA 23 traffic

Add these entries to your hosts file (requires admin/root):

# Point FIFA 23 FUT traffic to OpenFUT Bridge
127.0.0.1  fut.ea.com
127.0.0.1  utas.mob.v4.fut.ea.com
  • Windows: C:\Windows\System32\drivers\etc\hosts
  • macOS / Linux: /etc/hosts

Step 2 — Install the TLS certificate (HTTPS only)

{cert_section}

Step 3 — Launch FIFA 23

Start FIFA 23 and navigate to Ultimate Team. The bridge will capture and proxy FUT API calls. Open {bridge_url}/_bridge/admin in your browser to watch traffic in real time.

Supported endpoints

See /_bridge/status for a full list of mapped and unknown endpoints seen so far.

Troubleshooting

  • Game shows "FUT servers unavailable": make sure the hosts file is saved and DNS is flushed (ipconfig /flushdns on Windows).
  • Certificate error in browser: the self-signed cert must be trusted by the OS or the game's certificate store.
  • Bridge not reaching Core: check that openfut-core is running and CORE_URL is set correctly (default http://127.0.0.1:3000).

OpenFUT is an offline replacement backend for legitimate FIFA 23 owners. It does not connect to EA servers or enable online multiplayer.

"#, cert_section = if tls { format!( r#"

Download and install the bridge's self-signed CA certificate so FIFA 23 trusts HTTPS connections:

  1. Open {bridge_url}/_bridge/cert.pem and save it.
  2. Windows: double-click the file → "Install Certificate" → "Local Machine" → "Trusted Root Certification Authorities".
  3. macOS: double-click the file → Keychain Access → trust "Always".
  4. Linux: copy to /usr/local/share/ca-certificates/ and run update-ca-certificates.
"# ) } else { "

TLS is disabled — set TLS_ENABLED=true to enable HTTPS (required for FIFA 23 interception).

".to_string() } ); Html(guide) }