fix(og-image.php): re-use redirect logic + fix og image

This commit is contained in:
Cory Dransfeldt 2025-05-20 15:52:44 -07:00
parent 5168b13c99
commit 13b5b9c5cb
No known key found for this signature in database
4 changed files with 10 additions and 13 deletions

View file

@ -1,5 +1,7 @@
<?php
require __DIR__ . '/../server/utils/init.php';
$id = $_GET['id'] ?? null;
$class = $_GET['class'] ?? null;
$extension = $_GET['extension'] ?? 'png';
@ -24,12 +26,7 @@
curl_close($ch);
if ($httpCode !== 200 || $image === false || strpos($contentType, 'image/') !== 0) {
error_log("Failed to fetch image: $cdnUrl ($httpCode - $contentType)");
header("Location: /404", true, 302);
exit;
}
if ($httpCode !== 200 || $image === false || strpos($contentType, 'image/') !== 0) redirectTo404();
header("Content-Type: $contentType");