Merge pull request #1642 from influxdata/fix/basepath_json_feed-1640

Do not prefix basepath to external link for news feed
pull/10616/head
Jared Scheib 2017-06-20 12:44:44 -07:00 committed by GitHub
commit fe0890f134
3 changed files with 27 additions and 25 deletions

View File

@ -1,8 +1,6 @@
## v1.3.4.0 [unreleased]
## v1.3.3.1 [2017-06-20]
### Bug Fixes
### Features
### UI Improvements
1. [#1642](https://github.com/influxdata/chronograf/pull/1642): Do not prefix basepath to external link for news feed
## v1.3.3.0 [2017-06-19]

View File

@ -1,10 +1,13 @@
import AJAX from 'utils/ajax'
export const fetchJSONFeed = url =>
AJAX({
AJAX(
{
method: 'GET',
url,
// For explanation of why this header makes this work:
// https://stackoverflow.com/questions/22968406/how-to-skip-the-options-preflight-request-in-angularjs
headers: {'Content-Type': 'text/plain; charset=UTF-8'},
})
},
true // don't prefix route of external link with basepath
)

View File

@ -2,6 +2,13 @@ import axios from 'axios'
let links
// do not prefix route with basepath, ex. for external links
const addBasepath = (url, excludeBasepath) => {
const basepath = window.basepath || ''
return excludeBasepath ? url : `${basepath}${url}`
}
const generateResponseWithLinks = (response, {auth, logout, external}) => ({
...response,
auth: {links: auth},
@ -9,24 +16,18 @@ const generateResponseWithLinks = (response, {auth, logout, external}) => ({
external,
})
const AJAX = async ({
url,
resource,
id,
method = 'GET',
data = {},
params = {},
headers = {},
}) => {
const AJAX = async (
{url, resource, id, method = 'GET', data = {}, params = {}, headers = {}},
excludeBasepath
) => {
try {
const basepath = window.basepath || ''
let response
url = `${basepath}${url}`
url = addBasepath(url, excludeBasepath)
if (!links) {
const linksRes = (response = await axios({
url: `${basepath}/chronograf/v1`,
url: addBasepath('/chronograf/v1', excludeBasepath),
method: 'GET',
}))
links = linksRes.data
@ -34,8 +35,8 @@ const AJAX = async ({
if (resource) {
url = id
? `${basepath}${links[resource]}/${id}`
: `${basepath}${links[resource]}`
? addBasepath(`${links[resource]}/${id}`, excludeBasepath)
: addBasepath(`${links[resource]}`, excludeBasepath)
}
response = await axios({