From 1098dfd9283a725887221260d6dbf5f5b16a48e4 Mon Sep 17 00:00:00 2001 From: Andrew Martinez Date: Thu, 22 Jun 2023 14:16:59 -0400 Subject: [PATCH] Restores old /edge/client/v1 coverage of the root URL - restores /version for the c-sdk - fixes existing Go SDK enrolled configurations which will use the wrong API URL (non-prefixed) due to an old enrollment bug. --- controller/server/client-api.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/controller/server/client-api.go b/controller/server/client-api.go index 08857228d..11cf72c92 100644 --- a/controller/server/client-api.go +++ b/controller/server/client-api.go @@ -150,6 +150,13 @@ func (clientApi ClientApiHandler) newHandler(ae *env.AppEnv) http.Handler { handler := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { rw.Header().Set(ZitiInstanceId, ae.InstanceId) + //if not /edge prefix and not /fabric, translate to "/edge/client/v", this is a hack + //that should be removed once non-prefixed URLs are no longer used. + //This will affect older go-lang enrolled SDKs and the C-SDK. + if !strings.HasPrefix(r.URL.Path, controller.RestApiRootPath) && !strings.HasPrefix(r.URL.Path, "/fabric") && !strings.HasPrefix(r.URL.Path, "/.well-known") { + r.URL.Path = controller.ClientRestApiBaseUrlLatest + r.URL.Path + } + //translate /edge/v1 to /edge/client/v1 r.URL.Path = strings.Replace(r.URL.Path, controller.LegacyClientRestApiBaseUrlV1, controller.ClientRestApiBaseUrlLatest, 1)