diff --git a/api/config.go b/api/config.go index a87d07093a..30831bfa34 100644 --- a/api/config.go +++ b/api/config.go @@ -278,3 +278,7 @@ func getConsoleAnimatedLogin() bool { func getConsoleBrowserRedirectURL() string { return env.Get(ConsoleBrowserRedirectURL, "") } + +func getConsoleUseProxyForSharedURL() bool { + return strings.ToLower(env.Get(ConsoleUseProxyForSharedURL, "on")) == "on" +} diff --git a/api/consts.go b/api/consts.go index ab477b12f8..86e51095ca 100644 --- a/api/consts.go +++ b/api/consts.go @@ -49,6 +49,7 @@ const ( ConsoleDevMode = "CONSOLE_DEV_MODE" ConsoleAnimatedLogin = "CONSOLE_ANIMATED_LOGIN" ConsoleBrowserRedirectURL = "CONSOLE_BROWSER_REDIRECT_URL" + ConsoleUseProxyForSharedURL = "CONSOLE_USE_PROXY_FOR_SHARED_URL" LogSearchQueryAuthToken = "LOGSEARCH_QUERY_AUTH_TOKEN" SlashSeparator = "/" LocalAddress = "127.0.0.1" diff --git a/api/user_objects.go b/api/user_objects.go index f5f0464bf2..32fc99a942 100644 --- a/api/user_objects.go +++ b/api/user_objects.go @@ -1011,6 +1011,10 @@ func getShareObjectURL(ctx context.Context, client MCClient, r *http.Request, ve return nil, pErr.Cause } + if !getConsoleUseProxyForSharedURL() { + return &minioURL, nil + } + requestURL := getRequestURLWithScheme(r) encodedURL := base64.RawURLEncoding.EncodeToString([]byte(minioURL)) diff --git a/api/user_objects_test.go b/api/user_objects_test.go index 7abae34f95..a2a20b71d9 100644 --- a/api/user_objects_test.go +++ b/api/user_objects_test.go @@ -1062,6 +1062,25 @@ func Test_shareObject(t *testing.T) { wantError: nil, expected: "http://proxy-url.com:9012/console/subpath/api/v1/download-shared-object/aHR0cDovL3NvbWV1cmw", }, + { + test: "returns directly url with share link if use proxy for shared url env variable is off", + setEnvVars: func() { + t.Setenv(ConsoleUseProxyForSharedURL, "off") + }, + args: args{ + r: &http.Request{ + TLS: nil, + Host: "localhost:9090", + }, + versionID: "2121434", + expires: "30s", + shareFunc: func(_ context.Context, _ string, _ time.Duration) (string, *probe.Error) { + return "http://someurl", nil + }, + }, + wantError: nil, + expected: "http://someurl", + }, } for _, tt := range tests {