fix (favicon): canary favicon

before this commit, we've had issues with overrides which wouldn't set
the favicon properly
This commit is contained in:
MickaelK 2024-12-09 13:00:22 +11:00
parent 7828d0c315
commit 4b8926a3da
3 changed files with 7 additions and 4 deletions

View file

@ -187,10 +187,8 @@
}
customElements.define("component-nyan", NyanCatLoader);
</script>
<link rel="icon" href="./assets/{{ .version}}/logo/favicon.svg">
{{ else }}
<link rel="icon" href="favicon.ico">
{{ end }}
<link rel="icon" href="favicon.ico">
<title></title>
</head>
<body>

View file

@ -295,6 +295,11 @@ func ServeFrontofficeHandler(ctx *App, res http.ResponseWriter, req *http.Reques
ServeIndex("index.frontoffice.html")(ctx, res, req)
}
func ServeFavicon(ctx *App, res http.ResponseWriter, req *http.Request) {
r, _ := http.NewRequest(http.MethodGet, "/favicon.svg", nil)
ServeFile("/assets/logo/")(ctx, res, r)
}
func NotFoundHandler(ctx *App, res http.ResponseWriter, req *http.Request) {
if strings.Contains(req.Header.Get("accept"), "text/html") {
res.WriteHeader(http.StatusNotFound)

View file

@ -99,7 +99,7 @@ func Build(a App) *mux.Router {
r.HandleFunc(WithBase("/sw_cache.js"), NewMiddlewareChain(LegacyStaticHandler("/assets/worker/"), middlewares, a)).Methods("GET")
} else { // TODO: remove this after migration is done
r.PathPrefix(WithBase("/assets")).Handler(http.HandlerFunc(NewMiddlewareChain(ServeFile("/"), middlewares, a))).Methods("GET")
r.HandleFunc(WithBase("/favicon.ico"), NewMiddlewareChain(ServeFile("/assets/logo/"), middlewares, a)).Methods("GET")
r.HandleFunc(WithBase("/favicon.ico"), NewMiddlewareChain(ServeFavicon, middlewares, a)).Methods("GET")
}
// Other endpoints