diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index da40c11b..bf2df2d3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -104,4 +104,10 @@ class ApplicationController < ActionController::Base def svg_icon(icon_name, class: '') render_to_string(partial: "icons/#{icon_name}", locals: { class: }) end + + def maybe_redirect_com + return if request.domain != 'docuseal.co' + + redirect_to request.url.gsub('.co/', '.com/'), allow_other_host: true, status: :moved_permanently + end end diff --git a/app/controllers/start_form_controller.rb b/app/controllers/start_form_controller.rb index 3b7d0c14..c7fc9ae8 100644 --- a/app/controllers/start_form_controller.rb +++ b/app/controllers/start_form_controller.rb @@ -7,6 +7,7 @@ class StartFormController < ApplicationController skip_authorization_check around_action :with_browser_locale, only: %i[show completed] + before_action :maybe_redirect_com, only: %i[show completed] before_action :load_template def show diff --git a/app/controllers/submissions_preview_controller.rb b/app/controllers/submissions_preview_controller.rb index 640e6e64..65b3fff3 100644 --- a/app/controllers/submissions_preview_controller.rb +++ b/app/controllers/submissions_preview_controller.rb @@ -4,6 +4,8 @@ class SubmissionsPreviewController < ApplicationController skip_before_action :authenticate_user! skip_authorization_check + before_action :maybe_redirect_com, only: %i[show completed] + TTL = 40.minutes def show diff --git a/app/controllers/submit_form_controller.rb b/app/controllers/submit_form_controller.rb index 621849eb..642c3119 100644 --- a/app/controllers/submit_form_controller.rb +++ b/app/controllers/submit_form_controller.rb @@ -7,6 +7,8 @@ class SubmitFormController < ApplicationController skip_before_action :authenticate_user! skip_authorization_check + before_action :maybe_redirect_com, only: %i[show completed] + CONFIG_KEYS = [].freeze def show