chore: add support for external frontend URL in environment configuration
This commit is contained in:
parent
5b7fc9ae77
commit
0348d0b25a
@ -258,6 +258,9 @@ AZURE_APP_SECRET=
|
|||||||
# contact_inboxes with no conversation older than 90 days will be removed
|
# contact_inboxes with no conversation older than 90 days will be removed
|
||||||
# REMOVE_STALE_CONTACT_INBOX_JOB_STATUS=false
|
# REMOVE_STALE_CONTACT_INBOX_JOB_STATUS=false
|
||||||
|
|
||||||
|
# NOTE: Useful when running inside docker-compose network to link to external domain
|
||||||
|
FRONTEND_URL_EXTERNAL=
|
||||||
|
|
||||||
# Baileys API Whatsapp provider
|
# Baileys API Whatsapp provider
|
||||||
BAILEYS_PROVIDER_DEFAULT_CLIENT_NAME=Chatwoot
|
BAILEYS_PROVIDER_DEFAULT_CLIENT_NAME=Chatwoot
|
||||||
BAILEYS_PROVIDER_DEFAULT_URL=http://localhost:3025
|
BAILEYS_PROVIDER_DEFAULT_URL=http://localhost:3025
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
module FrontendUrlsHelper
|
module FrontendUrlsHelper
|
||||||
def frontend_url(path, **query_params)
|
def frontend_url(path, **query_params)
|
||||||
url_params = query_params.blank? ? '' : "?#{query_params.to_query}"
|
url_params = query_params.blank? ? '' : "?#{query_params.to_query}"
|
||||||
"#{root_url}app/#{path}#{url_params}"
|
host = ENV.fetch('FRONTEND_URL_EXTERNAL', root_url)
|
||||||
|
"#{host}app/#{path}#{url_params}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -13,5 +13,13 @@ describe FrontendUrlsHelper do
|
|||||||
expect(helper.frontend_url('dashboard', p1: 'p1', p2: 'p2')).to eq 'http://test.host/app/dashboard?p1=p1&p2=p2'
|
expect(helper.frontend_url('dashboard', p1: 'p1', p2: 'p2')).to eq 'http://test.host/app/dashboard?p1=p1&p2=p2'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with set FRONTEND_URL_EXTERNAL' do
|
||||||
|
it 'creates path correctly' do
|
||||||
|
with_modified_env 'FRONTEND_URL_EXTERNAL' => 'http://external.url/' do
|
||||||
|
expect(helper.frontend_url('dashboard')).to eq 'http://external.url/app/dashboard'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user