Remove schema from api url

pull/2591/head
saneery 5 years ago
parent 6aea0658bd
commit 0a647d0acb
  1. 6
      apps/block_scout_web/assets/js/lib/try_api.js
  2. 6
      apps/block_scout_web/assets/js/lib/try_eth_api.js
  3. 5
      apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex

@ -55,6 +55,10 @@ function handleSuccess (query, xhr, clickedButton) {
clickedButton.prop('disabled', false) clickedButton.prop('disabled', false)
} }
function dropDomain (url) {
return url.split('/').slice(1).join('/')
}
// Show 'Try it out' UI for a module/action. // Show 'Try it out' UI for a module/action.
$('button[data-selector*="btn-try-api"]').click(event => { $('button[data-selector*="btn-try-api"]').click(event => {
const clickedButton = $(event.target) const clickedButton = $(event.target)
@ -124,7 +128,7 @@ $('button[data-try-api-ui-button-type="execute"]').click(event => {
} }
$.ajax({ $.ajax({
url: composeRequestUrl(query), url: '/' + dropDomain(composeRequestUrl(query)),
success: (_data, _status, xhr) => { success: (_data, _status, xhr) => {
handleSuccess(query, xhr, clickedButton) handleSuccess(query, xhr, clickedButton)
}, },

@ -43,6 +43,10 @@ function parseInput (input) {
} }
} }
function dropDomain (url) {
return url.split('/').slice(1).join('/')
}
$('button[data-try-eth-api-ui-button-type="execute"]').click(event => { $('button[data-try-eth-api-ui-button-type="execute"]').click(event => {
const clickedButton = $(event.target) const clickedButton = $(event.target)
const module = clickedButton.attr('data-module') const module = clickedButton.attr('data-module')
@ -62,7 +66,7 @@ $('button[data-try-eth-api-ui-button-type="execute"]').click(event => {
const url = $('[data-endpoint-url]').attr('data-endpoint-url') const url = $('[data-endpoint-url]').attr('data-endpoint-url')
$.ajax({ $.ajax({
url: url, url: '/' + dropDomain(url),
type: 'POST', type: 'POST',
data: JSON.stringify(formData), data: JSON.stringify(formData),
dataType: 'json', dataType: 'json',

@ -38,13 +38,12 @@ defmodule BlockScoutWeb.APIDocsView do
url_params = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url] url_params = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url]
host = url_params[:host] host = url_params[:host]
path = url_params[:path] path = url_params[:path]
scheme = url_params[:scheme]
if host != "localhost" do if host != "localhost" do
"#{scheme}://#{host}#{path}" "#{host}#{path}"
else else
port = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:http][:port] port = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:http][:port]
"#{scheme}://#{host}:#{to_string(port)}" "#{host}:#{to_string(port)}"
end end
end end

Loading…
Cancel
Save