diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-31 03:07:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-31 03:07:06 +0300 |
commit | a3df40b2c393e1540d237938240ee12d2774cd13 (patch) | |
tree | e37c37374aabe93db474e85fe2615f88dbbd0566 /app/controllers | |
parent | c34d58a898c8e3c6d70609e2e6e4329df40c5aad (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/application_controller.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1e4b44efa60..ef489a65575 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -114,6 +114,24 @@ class ApplicationController < ActionController::Base content_security_policy do |p| next if p.directives.blank? + + if Rails.env.development? && Feature.enabled?(:vite) + vite_host = ViteRuby.instance.config.host + vite_port = ViteRuby.instance.config.port + vite_origin = "#{vite_host}:#{vite_port}" + http_origin = "http://#{vite_origin}" + ws_origin = "ws://#{vite_origin}" + wss_origin = "wss://#{vite_origin}" + gitlab_ws_origin = Gitlab::Utils.append_path(Gitlab.config.gitlab.url, 'vite-dev/') + http_path = Gitlab::Utils.append_path(http_origin, 'vite-dev/') + + connect_sources = p.directives['connect-src'] + p.connect_src(*(Array.wrap(connect_sources) | [ws_origin, wss_origin, http_path])) + + worker_sources = p.directives['worker-src'] + p.worker_src(*(Array.wrap(worker_sources) | [gitlab_ws_origin, http_path])) + end + next unless Gitlab::CurrentSettings.snowplow_enabled? && !Gitlab::CurrentSettings.snowplow_collector_hostname.blank? default_connect_src = p.directives['connect-src'] || p.directives['default-src'] |