fix: add FetchProxy
This will let us intercept fetch requests (until now we're only proxying
XMLHttpRequest), in order to fix the issues we're experiencing with some
features.
Bug: twpowertools:229
Change-Id: I277473c05479ca39bb6183a51855382124890bde
diff --git a/src/common/api.js b/src/common/api.js
index 8e0c19b..b7a1928 100644
--- a/src/common/api.js
+++ b/src/common/api.js
@@ -20,6 +20,9 @@
16: 'UNAUTHENTICATED',
};
+export const XClientHeader = 'X-Client';
+export const XClientValue = 'twpt';
+
// Function to wrap calls to the Community Console API with intelligent error
// handling.
export function CCApi(
@@ -42,6 +45,9 @@
.fetch(CC_API_BASE_URL + method + authuserPart, {
'headers': {
'content-type': 'text/plain; charset=utf-8',
+ // Used to exclude our requests from being handled by FetchProxy.
+ // FetchProxy will remove this header.
+ [XClientHeader]: XClientValue,
},
'body': JSON.stringify(data),
'method': 'POST',