From 6a1625d8e7dd343f4c7ddeeec3bb331330c91f41 Mon Sep 17 00:00:00 2001 From: Hunter Trujillo Date: Mon, 4 Dec 2017 16:47:23 -0700 Subject: [PATCH] Fix headers sent to Kapacitor proxy endpoint by clientside fetch. --- ui/src/kapacitor/apis/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ui/src/kapacitor/apis/index.js b/ui/src/kapacitor/apis/index.js index 4465f8aca..01155b43d 100644 --- a/ui/src/kapacitor/apis/index.js +++ b/ui/src/kapacitor/apis/index.js @@ -101,10 +101,16 @@ export const updateTask = async ( } } +const kapacitorLogHeaders = { + 'Content-Type': 'application/json', + Accept: 'application/json', +} + export const getLogStream = kapacitor => fetch(`${kapacitor.links.proxy}?path=/kapacitor/v1preview/logs`, { method: 'GET', - headers: {'Content-Type': 'application/json'}, + headers: kapacitorLogHeaders, + credentials: 'include', }) export const getLogStreamByRuleID = (kapacitor, ruleID) => @@ -112,7 +118,8 @@ export const getLogStreamByRuleID = (kapacitor, ruleID) => `${kapacitor.links.proxy}?path=/kapacitor/v1preview/logs?task=${ruleID}`, { method: 'GET', - headers: {'Content-Type': 'application/json'}, + headers: kapacitorLogHeaders, + credentials: 'include', } ) @@ -121,6 +128,8 @@ export const pingKapacitorVersion = async kapacitor => { const result = await AJAX({ method: 'GET', url: `${kapacitor.links.proxy}?path=/kapacitor/v1preview/ping`, + headers: kapacitorLogHeaders, + credentials: 'include', }) const kapVersion = result.headers['x-kapacitor-version'] return kapVersion === '' ? null : kapVersion