fix favicon

This commit is contained in:
sky22333
2026-07-12 01:30:17 +08:00
parent 79f23d13ad
commit 7e0b82f8f0
7 changed files with 6 additions and 31 deletions

View File

@@ -67,15 +67,15 @@ func registerFrontendRoutes(router *gin.Engine, enabled bool) {
router.GET("/images", notFound)
router.GET("/search", notFound)
router.GET("/assets/*filepath", notFound)
router.GET("/favicon.svg", notFound)
router.GET("/favicon.ico", notFound)
return
}
router.GET("/", serveSPA)
router.GET("/images", serveSPA)
router.GET("/search", serveSPA)
router.GET("/favicon.svg", func(c *gin.Context) {
serveEmbedFile(c, "dist/favicon.svg")
router.GET("/favicon.ico", func(c *gin.Context) {
serveEmbedFile(c, "dist/favicon.ico")
})
router.GET("/assets/*filepath", func(c *gin.Context) {
filepath := strings.TrimPrefix(c.Param("filepath"), "/")

View File

@@ -71,7 +71,7 @@ func TestFrontendDisabledRoutesReturnNotFound(t *testing.T) {
enableFrontend = false
`)
for _, path := range []string{"/", "/images", "/search", "/favicon.svg"} {
for _, path := range []string{"/", "/images", "/search", "/favicon.ico"} {
w := performRequest(router, http.MethodGet, path, "")
if w.Code != http.StatusNotFound {
t.Fatalf("%s status = %d, want 404", path, w.Code)

View File

@@ -213,7 +213,7 @@ func RateLimitMiddleware(limiter *IPRateLimiter) gin.HandlerFunc {
return func(c *gin.Context) {
path := c.Request.URL.Path
if path == "/" || path == "/images" || path == "/search" ||
path == "/favicon.svg" ||
path == "/favicon.ico" ||
strings.HasPrefix(path, "/assets/") {
c.Next()
return