@@ -90,3 +90,30 @@ func TestRegisterRoutesAppliesAuthToInstanceProxyPrefix(t *testing.T) {
9090 t .Fatalf ("expected /i/openclaw-tide-wind response to mention unauthenticated, got %q" , rec .Body .String ())
9191 }
9292}
93+
94+ func TestRegisterRoutesUsesConfiguredAPIPrefix (t * testing.T ) {
95+ t .Setenv ("SPRITZ_ROUTE_API_PATH_PREFIX" , "/control-api" )
96+
97+ s := & server {
98+ auth : authConfig {mode : authModeNone },
99+ internalAuth : internalAuthConfig {enabled : false },
100+ terminal : terminalConfig {enabled : false },
101+ routeModel : spritzRouteModelFromEnv (),
102+ }
103+ e := echo .New ()
104+ s .registerRoutes (e )
105+
106+ customReq := httptest .NewRequest (http .MethodGet , "/control-api/healthz" , nil )
107+ customRec := httptest .NewRecorder ()
108+ e .ServeHTTP (customRec , customReq )
109+ if customRec .Code != http .StatusOK {
110+ t .Fatalf ("expected configured api prefix to return 200, got %d" , customRec .Code )
111+ }
112+
113+ legacyReq := httptest .NewRequest (http .MethodGet , "/api/healthz" , nil )
114+ legacyRec := httptest .NewRecorder ()
115+ e .ServeHTTP (legacyRec , legacyReq )
116+ if legacyRec .Code != http .StatusNotFound {
117+ t .Fatalf ("expected legacy /api/healthz to return 404 when a custom prefix is configured, got %d" , legacyRec .Code )
118+ }
119+ }
0 commit comments