Merge pull request #1642 from influxdata/fix/basepath_json_feed-1640
Do not prefix basepath to external link for news feedpull/10616/head
commit
fe0890f134
|
@ -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]
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import AJAX from 'utils/ajax'
|
||||
|
||||
export const fetchJSONFeed = url =>
|
||||
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'},
|
||||
})
|
||||
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
|
||||
)
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in New Issue