From 24a0892160fe952dbca4c076651d34f8bd060b43 Mon Sep 17 00:00:00 2001 From: Ryan Prather Date: Mon, 11 Aug 2025 13:00:55 -0400 Subject: [PATCH] fix: index - fixed problem with files not pulling from server correct with MIME types --- public/index.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/public/index.php b/public/index.php index 6a1165a..4734829 100644 --- a/public/index.php +++ b/public/index.php @@ -3,6 +3,35 @@ use App\Kernel; if (file_exists(__DIR__.$_SERVER['REQUEST_URI']) && is_readable(__DIR__.$_SERVER['REQUEST_URI']) && is_file(__DIR__.$_SERVER['REQUEST_URI'])) { + $header = 'text/html'; + if (substr($_SERVER['REQUEST_URI'], -4) == '.css') + $header = 'text/css'; + elseif (substr($_SERVER['REQUEST_URI'], -3) == '.js') + $header = 'text/javascript'; + elseif (substr($_SERVER['REQUEST_URI'], -4) == '.ico') + $header = 'image/x-icon'; + elseif (substr($_SERVER['REQUEST_URI'], -4) == '.png') + $header = 'image/png'; + elseif (substr($_SERVER['REQUEST_URI'], -4) == '.jpg') + $header = 'image/jpeg'; + elseif (substr($_SERVER['REQUEST_URI'], -4) == '.gif') + $header = 'image/gif'; + elseif (substr($_SERVER['REQUEST_URI'], -3) == '.wo' || substr($_SERVER['REQUEST_URI'], -6) == '.woff2') + $header = 'font/woff2'; + elseif (substr($_SERVER['REQUEST_URI'], -4) == '.ttf') + $header = 'font/truetype'; + elseif (substr($_SERVER['REQUEST_URI'], -4) == '.eot' || substr($_SERVER['REQUEST_URI'], -5) == '.ttf-') + $header = 'application/vnd.ms-fontobject'; + elseif (substr($_SERVER['REQUEST_URI'], -4) == '.svg') + $header = 'image/svg+xml'; + elseif (substr($_SERVER['REQUEST_URI'], -5) == '.json') + $header = 'application/json'; + elseif (substr($_SERVER['REQUEST_URI'], -3) == '.otf') + $header = 'font/opentype'; + elseif (substr($_SERVER['REQUEST_URI'], -5) == '.woff') + $header = 'font/woff'; + + print header("Content-Type: $header; charset=UTF-8"); print file_get_contents(__DIR__.$_SERVER['REQUEST_URI']); exit; }