fix(web): correct SVG MIME type to image/svg+xml

Go's built-in mime.TypeByExtension returns 'image/svg' for .svg files,
but the correct MIME type per RFC 6838 is 'image/svg+xml'. This fix
registers the correct MIME type when setting up the static file server.

Fixes #1410
This commit is contained in:
曾文锋0668000834
2026-03-12 20:39:26 +08:00
parent 95716b106b
commit e4460d3815
+8
View File
@@ -4,6 +4,7 @@ import (
"embed"
"io/fs"
"log"
"mime"
"net/http"
"path"
"strings"
@@ -14,6 +15,13 @@ var frontendFS embed.FS
// registerEmbedRoutes sets up the HTTP handler to serve the embedded frontend files
func registerEmbedRoutes(mux *http.ServeMux) {
// Register correct MIME type for SVG files
// Go's built-in mime.TypeByExtension returns "image/svg" which is incorrect
// The correct MIME type per RFC 6838 is "image/svg+xml"
if err := mime.AddExtensionType(".svg", "image/svg+xml"); err != nil {
log.Printf("Warning: failed to register SVG MIME type: %v", err)
}
// Attempt to get the subdirectory 'dist' where Vite usually builds
subFS, err := fs.Sub(frontendFS, "dist")
if err != nil {