From 78c9d0d1bf7d5467c326754be8070065c62fd598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E6=96=87=E9=94=8B0668000834?= Date: Fri, 13 Mar 2026 09:09:29 +0800 Subject: [PATCH] fix(web): correct SVG MIME type from image/svg to image/svg+xml Go's mime package doesn't register .svg with the correct type by default, causing browsers to reject SVG resources when used with CSS mask-image. Fixes #1410 --- web/backend/embed.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/backend/embed.go b/web/backend/embed.go index 556fb7384..a20fc5dcd 100644 --- a/web/backend/embed.go +++ b/web/backend/embed.go @@ -4,6 +4,7 @@ import ( "embed" "io/fs" "log" + "mime" "net/http" "path" "strings" @@ -12,6 +13,12 @@ import ( //go:embed all:dist var frontendFS embed.FS +func init() { + // Register correct MIME type for SVG files + // Go's mime package doesn't register .svg with the correct type by default + mime.AddExtensionType(".svg", "image/svg+xml") +} + // registerEmbedRoutes sets up the HTTP handler to serve the embedded frontend files func registerEmbedRoutes(mux *http.ServeMux) { // Attempt to get the subdirectory 'dist' where Vite usually builds