From 85709d7b4319cc25c3cb87ecd1a619e12f5a0043 Mon Sep 17 00:00:00 2001 From: Giga Chubinidze Date: Thu, 16 Nov 2023 12:28:31 +0400 Subject: [PATCH] Fix setting of ASSET_SYNC_URL on the fronted [SCI-9665] --- app/controllers/asset_sync_controller.rb | 4 ++++ .../vue/shared/content/attachments/context_menu.vue | 3 ++- config/routes.rb | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/asset_sync_controller.rb b/app/controllers/asset_sync_controller.rb index 5cf619ccc..d957ee094 100644 --- a/app/controllers/asset_sync_controller.rb +++ b/app/controllers/asset_sync_controller.rb @@ -38,6 +38,10 @@ class AssetSyncController < ApplicationController render json: AssetSyncTokenSerializer.new(@asset_sync_token).as_json end + def api_url + render plain: Constants::ASSET_SYNC_URL + end + # private def conflicting_asset_copy_token diff --git a/app/javascript/vue/shared/content/attachments/context_menu.vue b/app/javascript/vue/shared/content/attachments/context_menu.vue index 43e262c4c..da89b61cd 100644 --- a/app/javascript/vue/shared/content/attachments/context_menu.vue +++ b/app/javascript/vue/shared/content/attachments/context_menu.vue @@ -142,7 +142,8 @@ try { const response = await axios.get(this.attachment.attributes.urls.open_locally); const data = response.data; - const syncUrl = GLOBAL_CONSTANTS.ASSET_SYNC_URL; + const syncUrlResponse = await axios.get('/asset_sync_api_url'); + const syncUrl = syncUrlResponse.data; await axios.post(syncUrl, data); } catch (error) { console.error("Error in request:", error); diff --git a/config/routes.rb b/config/routes.rb index 82b899f8a..5e01ca163 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1005,6 +1005,7 @@ Rails.application.routes.draw do get 'asset_sync/:asset_id', to: 'asset_sync#show', as: :asset_sync_show get 'asset_sync/:asset_id/download', to: 'asset_sync#download', as: :asset_sync_download put 'asset_sync', to: 'asset_sync#update' + get '/asset_sync_api_url', to: 'asset_sync#api_url' post 'global_activities', to: 'global_activities#index'