diff --git a/src/server/http/index.js b/src/server/http/index.js index 71830d85d72f3..c03a08ec30c52 100644 --- a/src/server/http/index.js +++ b/src/server/http/index.js @@ -111,7 +111,7 @@ module.exports = async function (kbnServer, server, config) { path: '/goto/{urlId}', handler: async function (request, reply) { const url = await shortUrlLookup.getUrl(request.params.urlId); - reply().redirect(url); + reply().redirect(config.get('server.basePath') + url); } }); diff --git a/src/ui/public/share/lib/url_shortener.js b/src/ui/public/share/lib/url_shortener.js index 3e29500d8d2f0..d20afb2a9af9e 100644 --- a/src/ui/public/share/lib/url_shortener.js +++ b/src/ui/public/share/lib/url_shortener.js @@ -1,15 +1,18 @@ +import chrome from 'ui/chrome'; + export default function createUrlShortener(Notifier, $http, $location) { const notify = new Notifier({ location: 'Url Shortener' }); - const baseUrl = `${$location.protocol()}://${$location.host()}:${$location.port()}`; + const basePath = chrome.getBasePath(); + const baseUrl = `${$location.protocol()}://${$location.host()}:${$location.port()}${basePath}`; async function shortenUrl(url) { const relativeUrl = url.replace(baseUrl, ''); const formData = { url: relativeUrl }; try { - const result = await $http.post('/shorten', formData); + const result = await $http.post(`${basePath}/shorten`, formData); return `${baseUrl}/goto/${result.data}`; } catch (err) {