Skip to content

Commit dca88fb

Browse files
authored
fix(Insight): skip signing keys when sending Insight job requests (#380)
1 parent 20a8b09 commit dca88fb

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/request.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,23 @@ const ajax = (method, resourceUrl, data, headers = {}, onprogress) => {
102102
return promise;
103103
};
104104

105-
const setHeaders = (sessionToken) => {
105+
const setHeaders = (sessionToken, signKey) => {
106106
const headers = {
107107
'X-LC-Id': AV.applicationId,
108108
'Content-Type': 'application/json;charset=UTF-8',
109109
};
110110
if (AV.masterKey && AV._useMasterKey) {
111-
headers['X-LC-Sign'] = sign(AV.masterKey, true);
111+
if (signKey) {
112+
headers['X-LC-Sign'] = sign(AV.masterKey, true);
113+
} else {
114+
headers['X-LC-Key'] = `${AV.masterKey},master`;
115+
}
112116
} else {
113-
headers['X-LC-Sign'] = sign(AV.applicationKey);
117+
if (signKey) {
118+
headers['X-LC-Sign'] = sign(AV.applicationKey);
119+
} else {
120+
headers['X-LC-Key'] = AV.applicationKey;
121+
}
114122
}
115123
if (AV._config.applicationProduction !== null) {
116124
headers['X-LC-Prod'] = AV._config.applicationProduction;
@@ -305,7 +313,7 @@ const AVRequest = (route, className, objectId, method, dataObject = {}, sessionT
305313
}
306314
return getServerURLPromise.then(() => {
307315
const apiURL = createApiUrl(route, className, objectId, method, dataObject);
308-
return setHeaders(sessionToken).then(
316+
return setHeaders(sessionToken, route !== 'bigquery').then(
309317
headers => ajax(method, apiURL, dataObject, headers)
310318
.then(
311319
null,

0 commit comments

Comments
 (0)