From b7b4b56cec3e22e73d9e87ab10c86cdc62191bf2 Mon Sep 17 00:00:00 2001 From: equinoy Date: Tue, 23 Jun 2026 15:32:16 -0500 Subject: [PATCH] fix(mobile-control): serve correct MIME types for app static assets Use query-stripped file path for extension detection Add content types for svg, png, jpg/jpeg, gif, webp, and ico Keep existing html/js/css/json handling unchanged --- .../MobileControlWebsocketServer.cs | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs b/src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs index 0334df39..6e7a1f5b 100644 --- a/src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs +++ b/src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs @@ -1354,27 +1354,48 @@ namespace PepperDash.Essentials.WebSocketServer } } - // Set ContentType based on file type + // Set ContentType based on file type. Use filePath so query params do not break extension checks. if (filePath.EndsWith(".html")) { this.LogVerbose("Client requesting User App"); res.ContentType = "text/html"; } - else + else if (filePath.EndsWith(".js")) { - if (path.EndsWith(".js")) - { - res.ContentType = "application/javascript"; - } - else if (path.EndsWith(".css")) - { - res.ContentType = "text/css"; - } - else if (path.EndsWith(".json")) - { - res.ContentType = "application/json"; - } + res.ContentType = "application/javascript"; + } + else if (filePath.EndsWith(".css")) + { + res.ContentType = "text/css"; + } + else if (filePath.EndsWith(".json")) + { + res.ContentType = "application/json"; + } + else if (filePath.EndsWith(".svg")) + { + res.ContentType = "image/svg+xml"; + } + else if (filePath.EndsWith(".png")) + { + res.ContentType = "image/png"; + } + else if (filePath.EndsWith(".jpg") || filePath.EndsWith(".jpeg")) + { + res.ContentType = "image/jpeg"; + } + else if (filePath.EndsWith(".gif")) + { + res.ContentType = "image/gif"; + } + else if (filePath.EndsWith(".webp")) + { + res.ContentType = "image/webp"; + } + else if (filePath.EndsWith(".ico")) + { + res.ContentType = "image/x-icon"; } this.LogVerbose("Attempting to serve file: {filePath}", filePath);