- Route CoinGecko API through /api/rates.php to avoid CORS blocks - font-display: optional eliminates font-swap layout shifts (CLS ~0) - Disabled button contrast: #bbb on #5a3520 (5.8:1 ratio) - Nginx font caching: 1 year, immutable
23 lines
624 B
PHP
23 lines
624 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
header('Cache-Control: public, max-age=60');
|
|
|
|
$url = 'https://api.coingecko.com/api/v3/simple/price?ids=monero&vs_currencies=eur,usd,chf';
|
|
|
|
$ch = curl_init($url);
|
|
curl_setopt_array($ch, [
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_TIMEOUT => 10,
|
|
CURLOPT_HTTPHEADER => ['Accept: application/json'],
|
|
]);
|
|
$response = curl_exec($ch);
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
curl_close($ch);
|
|
|
|
if ($response !== false && $httpCode === 200) {
|
|
echo $response;
|
|
} else {
|
|
http_response_code(502);
|
|
echo json_encode(['error' => 'Failed to fetch rates']);
|
|
}
|