@@ -16,17 +16,18 @@ var frontendFS embed.FS
1616// NewHandler creates a new HTTP handler for serving the embedded web UI
1717func NewHandler (logger * zap.SugaredLogger ) http.Handler {
1818 return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
19- // Clean the path
20- p := r .URL .Path
21- if p == "" || p == "/" {
22- p = "frontend/dist/index.html"
23- } else {
24- // Add frontend/dist prefix to all paths
25- p = "frontend/dist" + strings .TrimPrefix (p , "/" )
19+ // The /ui prefix is already stripped by http.StripPrefix in server.go
20+ // So paths come in as: "/" for index, "/assets/file.js" for assets
21+ p := strings .TrimPrefix (r .URL .Path , "/" )
22+ if p == "" {
23+ p = "index.html"
2624 }
2725
26+ // Build full path within embedded FS
27+ fullPath := "frontend/dist/" + p
28+
2829 // Try to read the file
29- content , err := fs .ReadFile (frontendFS , p )
30+ content , err := fs .ReadFile (frontendFS , fullPath )
3031 if err != nil {
3132 // If file not found, serve index.html (for SPA routing)
3233 content , err = fs .ReadFile (frontendFS , "frontend/dist/index.html" )
@@ -35,11 +36,11 @@ func NewHandler(logger *zap.SugaredLogger) http.Handler {
3536 http .Error (w , "Not found" , http .StatusNotFound )
3637 return
3738 }
38- p = "frontend/dist/index.html"
39+ fullPath = "frontend/dist/index.html"
3940 }
4041
4142 // Set content type based on file extension
42- ext := path .Ext (p )
43+ ext := path .Ext (fullPath )
4344 contentType := "text/html"
4445 switch ext {
4546 case ".js" :
0 commit comments