Skip to content

Commit

Permalink
[Dataset Quality][Observability Onboarding] Update axios headers (#20…
Browse files Browse the repository at this point in the history
…2412)

## 📓 Summary

To ensure Kibana features/tests don't break after the update to v9.0.0,
we need to provide the `'x-elastic-internal-origin': 'kibana'` header is
set on API providers that are not the internal core HTTP service.

These changes fix a couple of utilities using the axios library for
testing purpose.

---------

Co-authored-by: Marco Antonio Ghiani <[email protected]>
  • Loading branch information
tonyghiani and Marco Antonio Ghiani authored Dec 3, 2024
1 parent d1e5aa1 commit a75a92b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ export async function callKibana<T>({
...options,
baseURL: baseUrl,
auth: { username, password },
headers: { 'kbn-xsrf': 'true', ...options.headers },
headers: { 'kbn-xsrf': 'true', 'x-elastic-internal-origin': 'kibana', ...options.headers },
});
return data;
}

const getBaseUrl = once(async (kibanaHostname: string) => {
try {
await axios.request({ url: kibanaHostname, maxRedirects: 0 });
await axios.request({
url: kibanaHostname,
maxRedirects: 0,
headers: { 'x-elastic-internal-origin': 'kibana' },
});
} catch (e) {
if (isAxiosError(e)) {
const location = e.response?.headers?.location ?? '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ export async function callKibana<T>({
...options,
baseURL: baseUrl,
auth: { username, password },
headers: { 'kbn-xsrf': 'true', ...options.headers },
headers: { 'kbn-xsrf': 'true', 'x-elastic-internal-origin': 'kibana', ...options.headers },
});
return data;
}

const getBaseUrl = once(async (kibanaHostname: string) => {
try {
await axios.request({ url: kibanaHostname, maxRedirects: 0 });
await axios.request({
url: kibanaHostname,
maxRedirects: 0,
headers: { 'x-elastic-internal-origin': 'kibana' },
});
} catch (e) {
if (isAxiosError(e)) {
const location = e.response?.headers?.location ?? '';
Expand Down

0 comments on commit a75a92b

Please sign in to comment.