From aa47b9bf5c02a9c850277ec3d25fcd81c721b736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 14 Apr 2017 19:01:08 +0200 Subject: [PATCH] refactoring: simplified backend_srv and subUrl handling, #8122 --- public/app/core/services/backend_srv.ts | 10 ++++------ public/app/plugins/panel/gettingstarted/module.ts | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/public/app/core/services/backend_srv.ts b/public/app/core/services/backend_srv.ts index 3159e87882b..041cd1ab1db 100644 --- a/public/app/core/services/backend_srv.ts +++ b/public/app/core/services/backend_srv.ts @@ -66,16 +66,14 @@ export class BackendSrv { var requestIsLocal = !options.url.match(/^http/); var firstAttempt = options.retry === 0; - if (requestIsLocal) { if (this.contextSrv.user && this.contextSrv.user.orgId) { options.headers = options.headers || {}; options.headers['X-Grafana-Org-Id'] = this.contextSrv.user.orgId; } - if (!options.hasSubUrl) { - options.url = config.appSubUrl + options.url; - options.hasSubUrl = true; + if (options.url.indexOf("/") === 0) { + options.url = options.url.substring(1); } } @@ -142,8 +140,8 @@ export class BackendSrv { options.headers['X-Grafana-Org-Id'] = this.contextSrv.user.orgId; } - if (!options.hasSubUrl && options.retry === 0) { - options.url = config.appSubUrl + options.url; + if (options.url.indexOf("/") === 0) { + options.url = options.url.substring(1); } if (options.headers && options.headers.Authorization) { diff --git a/public/app/plugins/panel/gettingstarted/module.ts b/public/app/plugins/panel/gettingstarted/module.ts index 4ebc76f942e..f0ee0bf36e4 100644 --- a/public/app/plugins/panel/gettingstarted/module.ts +++ b/public/app/plugins/panel/gettingstarted/module.ts @@ -58,7 +58,7 @@ class GettingStartedPanelCtrl extends PanelCtrl { icon: 'icon-gf icon-gf-users', href: 'org/users?gettingstarted', check: () => { - return this.backendSrv.get('api/org/users').then(res => { + return this.backendSrv.get('/api/org/users').then(res => { return res.length > 1; }); } @@ -71,7 +71,7 @@ class GettingStartedPanelCtrl extends PanelCtrl { icon: 'icon-gf icon-gf-apps', href: 'https://grafana.com/plugins?utm_source=grafana_getting_started', check: () => { - return this.backendSrv.get('api/plugins', {embedded: 0, core: 0}).then(plugins => { + return this.backendSrv.get('/api/plugins', {embedded: 0, core: 0}).then(plugins => { return plugins.length > 0; }); }