chore: Improve Helpcenter custom domains (#5456)

- Support rendering articles over frontend URL
- Support rendering articles over help center URL
- Support rendering help center home page in the custom domain root
This commit is contained in:
Sojan Jose
2022-09-20 06:06:01 +05:30
committed by GitHub
parent a773ad7d08
commit 99de8f4500
10 changed files with 35 additions and 23 deletions

View File

@@ -7,14 +7,15 @@ class PublicController < ActionController::Base
private
def ensure_custom_domain_request
custom_domain = request.host
domain = request.host
@portals = ::Portal.where(custom_domain: custom_domain)
return if [URI.parse(ENV.fetch('FRONTEND_URL', '')).host, URI.parse(ENV.fetch('HELPCENTER_URL', '')).host].include?(domain)
return if @portals.present?
@portal = ::Portal.find_by(custom_domain: domain)
return if @portal.present?
render json: {
error: "Domain: #{custom_domain} is not registered with us. \
error: "Domain: #{domain} is not registered with us. \
Please send us an email at support@chatwoot.com with the custom domain name and account API key"
}, status: :unauthorized and return
end