Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Modify the renderer ENV to include the host name and relative URL root

Oliver Günther6445ab1db51f
diff --git a/app/controllers/work_packages/bulk_error_message.rb b/app/controllers/work_packages/bulk_error_message.rb
index 336a9e395e6..9eae4a0dd10 100644
--- a/app/controllers/work_packages/bulk_error_message.rb
+++ b/app/controllers/work_packages/bulk_error_message.rb
@@ -33,9 +33,9 @@ module WorkPackages::BulkErrorMessage
private
def bulk_error_message(selected_work_packages, service_result)
- ApplicationController.renderer.render_to_string partial: 'work_packages/bulk/errors',
- locals: { service_result:,
- selected_work_packages: }
+ ApplicationController.renderer.render partial: 'work_packages/bulk/errors',
+ locals: { service_result:,
+ selected_work_packages: }
end
end
end
diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb
index 89d2efab2ba..79781a72874 100644
--- a/config/initializers/application_controller_renderer.rb
+++ b/config/initializers/application_controller_renderer.rb
@@ -1,8 +1,13 @@
# Be sure to restart your server when you modify this file.
-# ActiveSupport::Reloader.to_prepare do
-# ApplicationController.renderer.defaults.merge!(
-# http_host: 'example.org',
-# https: false
-# )
-# end
+# Just modifying the defaults do not work
+# see:
+# - https://github.com/hotwired/turbo-rails/issues/155
+# - https://github.com/rails/rails/issues/41795
+ActiveSupport::Reloader.to_prepare do
+ ApplicationController.renderer.instance_variable_get(:@env).merge!(
+ 'HTTP_HOST' => Setting.host_name,
+ 'HTTPS' => Setting.https?,
+ 'SCRIPT_NAME' => OpenProject::Configuration.rails_relative_url_root
+ )
+end