ui: Use credentials for all HTTP API requests (#14343)

Adds withCredentials/credentials to all HTTP API requests.
This commit is contained in:
John Cowen 2022-09-01 18:15:06 +01:00 committed by GitHub
parent fd8b367dc0
commit fc6b2ccb00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

4
.changelog/14343.txt Normal file
View File

@ -0,0 +1,4 @@
```release-note:feature
ui: Use withCredentials for all HTTP API requests
```

View File

@ -210,6 +210,7 @@ export default class HttpService extends Service {
return this.settings.findBySlug('token').then(token => { return this.settings.findBySlug('token').then(token => {
return fetch(`${path}`, { return fetch(`${path}`, {
...params, ...params,
credentials: 'include',
headers: { headers: {
'X-Consul-Token': typeof token.SecretID === 'undefined' ? '' : token.SecretID, 'X-Consul-Token': typeof token.SecretID === 'undefined' ? '' : token.SecretID,
...params.headers, ...params.headers,

View File

@ -27,6 +27,7 @@ export default function(parseHeaders, XHR) {
}; };
Object.entries(headers).forEach(([key, value]) => xhr.setRequestHeader(key, value)); Object.entries(headers).forEach(([key, value]) => xhr.setRequestHeader(key, value));
options.beforeSend(xhr); options.beforeSend(xhr);
xhr.withCredentials = true;
xhr.send(options.body); xhr.send(options.body);
return xhr; return xhr;
}; };