mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-07-02 10:38:16 +00:00
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
This commit is contained in:
parent
a1d168c4ed
commit
b7b4b56cec
1 changed files with 35 additions and 14 deletions
|
|
@ -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"))
|
if (filePath.EndsWith(".html"))
|
||||||
{
|
{
|
||||||
this.LogVerbose("Client requesting User App");
|
this.LogVerbose("Client requesting User App");
|
||||||
|
|
||||||
res.ContentType = "text/html";
|
res.ContentType = "text/html";
|
||||||
}
|
}
|
||||||
else
|
else if (filePath.EndsWith(".js"))
|
||||||
{
|
|
||||||
if (path.EndsWith(".js"))
|
|
||||||
{
|
{
|
||||||
res.ContentType = "application/javascript";
|
res.ContentType = "application/javascript";
|
||||||
}
|
}
|
||||||
else if (path.EndsWith(".css"))
|
else if (filePath.EndsWith(".css"))
|
||||||
{
|
{
|
||||||
res.ContentType = "text/css";
|
res.ContentType = "text/css";
|
||||||
}
|
}
|
||||||
else if (path.EndsWith(".json"))
|
else if (filePath.EndsWith(".json"))
|
||||||
{
|
{
|
||||||
res.ContentType = "application/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);
|
this.LogVerbose("Attempting to serve file: {filePath}", filePath);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue