<?php

$symbol = $_GET["symbol"] ?? "XAUUSD";
$tf     = $_GET["timeframe"] ?? "M5";

$url="http://127.0.0.1:8001/replay_data?symbol=$symbol&timeframe=$tf";

$ch=curl_init($url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_TIMEOUT,20);
$response=curl_exec($ch);

if($response===false){
    http_response_code(500);
    echo json_encode(["error"=>"FEED_UNREACHABLE"]);
    exit;
}

curl_close($ch);
header("Content-Type:application/json");
echo $response;