From 63dbe7024dc8ea819a087e22080d6d67c21f68be Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Mon, 10 May 2021 20:35:29 +0200 Subject: [PATCH] Fix failed mount on disabled webapps --- app/servers.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/servers.go b/app/servers.go index fc09832df..288d221ae 100644 --- a/app/servers.go +++ b/app/servers.go @@ -56,10 +56,10 @@ func (app *CortezaApp) mountHttpRoutes(r chi.Router) { ) func() { - if ho.ApiEnabled && ho.ApiBaseUrl == ho.WebappBaseUrl { + if ho.WebappEnabled && ho.ApiEnabled && ho.ApiBaseUrl == ho.WebappBaseUrl { app.Log. WithOptions(zap.AddStacktrace(zap.PanicLevel)). - Warn("client web applications and api can not use the same base URL: " + ho.WebappBaseUrl) + Warn("client web applications and api can not use the same base URL: '" + ho.WebappBaseUrl + "'") ho.WebappEnabled = false } @@ -84,10 +84,11 @@ func (app *CortezaApp) mountHttpRoutes(r chi.Router) { func() { if !ho.ApiEnabled { app.Log.Info("JSON REST API disabled") + return } - r.Route(ho.ApiBaseUrl, func(r chi.Router) { - var fullpathAPI = options.CleanBase(ho.BaseUrl, ho.ApiBaseUrl) + r.Route("/"+strings.TrimPrefix(ho.ApiBaseUrl, "/"), func(r chi.Router) { + var fullpathAPI = "/" + strings.TrimPrefix(options.CleanBase(ho.BaseUrl, ho.ApiBaseUrl), "/") app.Log.Info( "JSON REST API enabled",