Skip to content

Commit

Permalink
[7.x] Use credentials: same-origin when we fetch translations JSON. (
Browse files Browse the repository at this point in the history
  • Loading branch information
azasypkin authored Mar 28, 2019
1 parent 7cf702b commit 9abeb16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-i18n/src/core/i18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
6 changes: 5 additions & 1 deletion packages/kbn-i18n/src/core/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down

0 comments on commit 9abeb16

Please sign in to comment.