From c4ac8a9c93a99b5c650048adca5bdfc796ede1a7 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Wed, 8 Oct 2025 20:43:58 +0200 Subject: [PATCH] Fix path loading error Signed-off-by: Bryan Frimin --- pkg/server/server.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkg/server/server.go b/pkg/server/server.go index f30ee8516..036e8ef54 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -18,6 +18,7 @@ package server import ( "context" "net/http" + "strings" "github.com/getprobo/probo/pkg/agents" "github.com/getprobo/probo/pkg/connector" @@ -119,6 +120,7 @@ func (s *Server) setupRoutes() { // Trust center routes by slug s.router.Route("/trust/{slug}", func(r chi.Router) { r.Use(s.loadTrustCenterBySlug) + r.Use(s.stripTrustSlugPrefix) r.Mount("/", s.trustCenterRouter()) }) @@ -215,6 +217,28 @@ func (s *Server) addTrustCenterToContext(ctx context.Context, tenantID, organiza return ctx } +// stripTrustSlugPrefix middleware strips /trust/{slug} from the path +func (s *Server) stripTrustSlugPrefix(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + slug := chi.URLParam(r, "slug") + prefix := "/trust/" + slug + + // Strip the prefix from the path + if r.URL.Path == prefix { + // Redirect to trailing slash for proper asset resolution + http.Redirect(w, r, prefix+"/", http.StatusMovedPermanently) + return + } + + r.URL.Path = strings.TrimPrefix(r.URL.Path, prefix) + if r.URL.Path == "" { + r.URL.Path = "/" + } + + next.ServeHTTP(w, r) + }) +} + // trustCenterRouter returns a router for trust center content (API + frontend) func (s *Server) trustCenterRouter() chi.Router { r := chi.NewRouter()