Skip to content

Commit 93935a3

Browse files
Merge pull request #18 from GetStream/improve-workflows
fixed app navigation
2 parents 1cf60da + bc23575 commit 93935a3

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

app/components/sidebar.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,18 @@ export default function Sidebar() {
3737
</Button>
3838
<Button
3939
asChild
40-
variant={path === "/metrics" ? "secondary" : "ghost"}
40+
variant={
41+
["/metrics", "/metrics/"].includes(path) ? "secondary" : "ghost"
42+
}
4143
size="icon-lg"
4244
className="rounded-full"
4345
>
4446
<Link href="/metrics">
4547
<ServerIcon
4648
stroke={
47-
path === "/metrics" ? "var(--color-primary)" : "currentColor"
49+
["/metrics", "/metrics/"].includes(path)
50+
? "var(--color-primary)"
51+
: "currentColor"
4852
}
4953
/>
5054
</Link>

cmd/main.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,28 +76,27 @@ func main() {
7676
// In Docker, we will copy the built 'out' directory to 'public'
7777
staticDir := "./public"
7878
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
79-
path := staticDir + r.URL.Path
80-
81-
// Check if exact file exists (e.g., /favicon.ico, /_next/static/...)
82-
if info, err := os.Stat(path); err == nil && !info.IsDir() {
83-
http.ServeFile(w, r, path)
84-
return
79+
// Clean the path (remove trailing slashes except for root)
80+
urlPath := r.URL.Path
81+
if urlPath != "/" && urlPath[len(urlPath)-1] == '/' {
82+
urlPath = urlPath[:len(urlPath)-1]
8583
}
84+
path := staticDir + urlPath
8685

87-
// For routes like /metrics, try serving metrics.html (Next.js static export)
88-
if r.URL.Path != "/" {
86+
// For non-root paths, try serving the .html file first (Next.js static export)
87+
// This handles /metrics -> metrics.html
88+
if urlPath != "/" {
8989
htmlPath := path + ".html"
9090
if info, err := os.Stat(htmlPath); err == nil && !info.IsDir() {
9191
http.ServeFile(w, r, htmlPath)
9292
return
9393
}
94+
}
9495

95-
// Also check for directory with index.html (e.g., /metrics/index.html)
96-
indexPath := path + "/index.html"
97-
if info, err := os.Stat(indexPath); err == nil && !info.IsDir() {
98-
http.ServeFile(w, r, indexPath)
99-
return
100-
}
96+
// Check if exact file exists (e.g., /favicon.ico, /_next/static/...)
97+
if info, err := os.Stat(path); err == nil && !info.IsDir() {
98+
http.ServeFile(w, r, path)
99+
return
101100
}
102101

103102
// Default: serve index.html (home page or SPA fallback)

0 commit comments

Comments
 (0)