diff --git a/app/controllers/concerns/web_app_controller_concern.rb b/app/controllers/concerns/web_app_controller_concern.rb index 39fc948e909..5a540d17b44 100644 --- a/app/controllers/concerns/web_app_controller_concern.rb +++ b/app/controllers/concerns/web_app_controller_concern.rb @@ -6,6 +6,7 @@ module WebAppControllerConcern included do vary_by 'Accept, Accept-Language, Cookie' + before_action :adjust_format_for_zip_tlds before_action :redirect_unauthenticated_to_permalinks! before_action :set_referer_header before_action :redirect_to_tos_interstitial! @@ -46,6 +47,14 @@ module WebAppControllerConcern protected + # This endpoint will never serve zip files, but may serve paths ending with `.zip` due to the `.zip` TLD. + # When that happens from a browser, Rails will unfortunately determine the requested format to be `:zip` + # instead of `:html`, so override this. + # We don't just override `format` in all cases, because we want to handle `:json` as well. + def adjust_format_for_zip_tlds + request.format = :html if request.format == :zip + end + def redirect_to_tos_interstitial! return unless current_user&.require_tos_interstitial?