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
This commit is contained in:
曾文锋0668000834 2026-03-13 09:09:29 +08:00
parent 19835b2f60
commit 78c9d0d1bf

View file

@ -4,6 +4,7 @@ import (
"embed" "embed"
"io/fs" "io/fs"
"log" "log"
"mime"
"net/http" "net/http"
"path" "path"
"strings" "strings"
@ -12,6 +13,12 @@ import (
//go:embed all:dist //go:embed all:dist
var frontendFS embed.FS 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 // registerEmbedRoutes sets up the HTTP handler to serve the embedded frontend files
func registerEmbedRoutes(mux *http.ServeMux) { func registerEmbedRoutes(mux *http.ServeMux) {
// Attempt to get the subdirectory 'dist' where Vite usually builds // Attempt to get the subdirectory 'dist' where Vite usually builds