fix: fixed routing for assets e5055391
Steve · 2026-06-08 23:57 2 file(s) · +14 −3
apps/kepler/docker-compose.yml +1 −0
10 10
      - PORT=${PORT:-4747}
11 11
      - KEPLER_REPO_ROOT=/data/repos
12 12
      - KEPLER_SITE_NAME=${KEPLER_SITE_NAME:-kepler}
13 +
      - KEPLER_BASE_URL=${KEPLER_BASE_URL:-http://localhost:4747}
13 14
    volumes:
14 15
      - ${KEPLER_REPO_ROOT:-./repos}:/data/repos:ro
15 16
    restart: unless-stopped
apps/kepler/routes.go +13 −3
30 30
		w.Header().Set("Access-Control-Allow-Origin", "*")
31 31
		_, _ = w.Write(data)
32 32
	})
33 -
	mux.HandleFunc("GET /assets/{name}", func(w http.ResponseWriter, r *http.Request) {
34 -
		name := r.PathValue("name")
33 +
	// Static icon/manifest assets. Registered as explicit literal paths so
34 +
	// they stay more specific than the "/{repo}/..." routes (a wildcard
35 +
	// "/assets/{name}" would be ambiguous against "/{repo}/refs" etc.).
36 +
	staticAsset := func(w http.ResponseWriter, r *http.Request) {
37 +
		name := path.Base(r.URL.Path)
35 38
		data, err := appFS.ReadFile("static/" + name)
36 39
		if err != nil {
37 40
			http.NotFound(w, r)
44 47
		w.Header().Set("Content-Type", ct)
45 48
		w.Header().Set("Cache-Control", "public, max-age=86400")
46 49
		_, _ = w.Write(data)
47 -
	})
50 +
	}
51 +
	for _, name := range []string{
52 +
		"og.png", "favicon.ico", "favicon-16x16.png", "favicon-32x32.png",
53 +
		"apple-touch-icon.png", "android-chrome-192x192.png",
54 +
		"android-chrome-512x512.png", "site.webmanifest",
55 +
	} {
56 +
		mux.HandleFunc("GET /assets/"+name, staticAsset)
57 +
	}
48 58
49 59
	mux.HandleFunc("GET /{$}", a.indexHandler)
50 60
	mux.HandleFunc("GET /{repo}", a.repoHandler)