Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions common/utils/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class Api {
operation.setContext(({ headers = {} }) => ({
headers: {
...headers,
...(this.getImpersonationHeaders() || {})
...(this.getImpersonationHeaders() || {}),
"X-CSRF-TOKEN": readCookie("csrf_access_token")
}
}));
return forward(operation);
Expand Down Expand Up @@ -168,6 +169,10 @@ class Api {
...impersonationHeaders
};
}
options.headers = {
...options.headers,
"X-CSRF-TOKEN": readCookie("csrf_access_token")
};
const response = await this._fetch(queryInfo, options);
if (response.status !== 200) {
const error = new Error("Response status is not 200");
Expand Down Expand Up @@ -211,7 +216,8 @@ class Api {
let refreshResponse;
try {
refreshResponse = await this._fetch(HTTP_QUERIES.refresh, {
timeout: 12000
timeout: 12000,
headers: { "X-CSRF-TOKEN": readCookie("csrf_refresh_token") }
});
} catch (err) {
const newError = new Error(err.message);
Expand Down Expand Up @@ -351,7 +357,10 @@ class Api {
try {
await this.nonConcurrentQueryQueue.execute(
async () =>
await this._fetch(HTTP_QUERIES.logout, { timeout: 8000 })
await this._fetch(HTTP_QUERIES.logout, {
timeout: 8000,
headers: { "X-CSRF-TOKEN": readCookie("csrf_refresh_token") }
})
);
} catch (err) {
if (failOnError) throw err;
Expand Down