summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-06-20 14:00:13 +0000
committerDouwe Maan <douwe@gitlab.com>2018-06-20 14:00:13 +0000
commit00518d261d2e5b751bb5da93531880d4b3eb4250 (patch)
tree1b3f4f8c163ed68dcb37814cea052be7a955d6bb /lib
parentb349c01c6a71ac1f486b8ee86ce96ef48ac04ed8 (diff)
parentb612670cc0a9eabce5d0f8aa86e93823a4639c04 (diff)
downloadgitlab-ce-00518d261d2e5b751bb5da93531880d4b3eb4250.tar.gz
Merge branch 'fix/favicon-cross-origin' into 'master'
Fix: Serve favicon image always from the main GitLab domain to avoid issues with CORS Closes #47802 See merge request gitlab-org/gitlab-ce!19810
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/favicon.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/gitlab/favicon.rb b/lib/gitlab/favicon.rb
index faf7016d73a..d512fc58e46 100644
--- a/lib/gitlab/favicon.rb
+++ b/lib/gitlab/favicon.rb
@@ -2,10 +2,10 @@ module Gitlab
class Favicon
class << self
def main
- return appearance_favicon.url if appearance_favicon.exists?
-
image_name =
- if Gitlab::Utils.to_boolean(ENV['CANARY'])
+ if appearance_favicon.exists?
+ appearance_favicon.url
+ elsif Gitlab::Utils.to_boolean(ENV['CANARY'])
'favicon-yellow.png'
elsif Rails.env.development?
'favicon-blue.png'
@@ -13,7 +13,7 @@ module Gitlab
'favicon.png'
end
- ActionController::Base.helpers.image_path(image_name)
+ ActionController::Base.helpers.image_path(image_name, host: host)
end
def status_overlay(status_name)
@@ -22,7 +22,7 @@ module Gitlab
"#{status_name}.png"
)
- ActionController::Base.helpers.image_path(path)
+ ActionController::Base.helpers.image_path(path, host: host)
end
def available_status_names
@@ -35,6 +35,16 @@ module Gitlab
private
+ # we only want to create full urls when there's a different asset_host
+ # configured.
+ def host
+ if Gitlab::Application.config.asset_host.nil? || Gitlab::Application.config.asset_host == Gitlab.config.gitlab.base_url
+ nil
+ else
+ Gitlab.config.gitlab.base_url
+ end
+ end
+
def appearance
RequestStore.store[:appearance] ||= (Appearance.current || Appearance.new)
end