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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user