Commit 34a847aa authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Fix Speedscope flamegraphs when asset host is set

This does not work when the Speedscope HTML is loaded from another
domain because the blob will be from another origin and would be blocked
by the browser.
parent 835b633a
......@@ -44,7 +44,7 @@ module Gitlab
headers = { 'Content-Type' => 'text/html' }
path = request.env['PATH_INFO'].sub('//', '/')
speedscope_url = ActionController::Base.helpers.asset_url('/-/speedscope/index.html')
speedscope_path = ::Gitlab::Utils.append_path(::Gitlab.config.gitlab.relative_url_root, '/-/speedscope/index.html')
html = <<~HTML
<!DOCTYPE html>
......@@ -64,7 +64,7 @@ module Gitlab
var iframe = document.createElement('IFRAME');
iframe.setAttribute('id', 'speedscope-iframe');
document.body.appendChild(iframe);
var iframeUrl = '#{speedscope_url}#profileURL=' + objUrl + '&title=' + 'Flamegraph for #{CGI.escape(path)}';
var iframeUrl = '#{speedscope_path}#profileURL=' + objUrl + '&title=' + 'Flamegraph for #{CGI.escape(path)}';
iframe.setAttribute('src', iframeUrl);
</script>
</body>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment