[7.0] Use credentials: same-origin when we fetch translations JSON. (#34125)

This commit is contained in:
Aleh Zasypkin 2019-03-28 23:56:47 +01:00 committed by GitHub
parent bb68ec9ea7
commit 7087d402c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -921,7 +921,7 @@ describe('I18n engine', () => {
await expect(i18n.load('some-url')).resolves.toBeUndefined();
expect(mockFetch).toHaveBeenCalledTimes(1);
expect(mockFetch).toHaveBeenCalledWith('some-url');
expect(mockFetch).toHaveBeenCalledWith('some-url', { credentials: 'same-origin' });
expect(i18n.getTranslation()).toEqual(translations);
});

View file

@ -240,7 +240,11 @@ export function init(newTranslation?: Translation) {
* @param translationsUrl URL pointing to the JSON bundle with translations.
*/
export async function load(translationsUrl: string) {
const response = await fetch(translationsUrl);
// Once this package is integrated into core Kibana we should switch to an abstraction
// around `fetch` provided by the platform, e.g. `kfetch`.
const response = await fetch(translationsUrl, {
credentials: 'same-origin',
});
if (response.status >= 300) {
throw new Error(`Translations request failed with status code: ${response.status}`);