Skip to content

Commit be73b28

Browse files
committed
fix(Insight): skip signing keys when sending Insight job requests
Conflicts: src/request.js
1 parent 67ce4ed commit be73b28

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/request.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,15 @@ const ajax = (method, resourceUrl, data, headers = {}, onprogress) => {
100100
});
101101
};
102102

103-
const setHeaders = (authOptions = {}) => {
103+
const setAppId = (headers, signKey) => {
104+
if (signKey) {
105+
headers['X-LC-Sign'] = sign(AV.applicationKey);
106+
} else {
107+
headers['X-LC-Key'] = AV.applicationKey;
108+
}
109+
};
110+
111+
const setHeaders = (authOptions = {}, signKey) => {
104112
const headers = {
105113
'X-LC-Id': AV.applicationId,
106114
'Content-Type': 'application/json;charset=UTF-8',
@@ -113,13 +121,17 @@ const setHeaders = (authOptions = {}) => {
113121
}
114122
if (useMasterKey) {
115123
if (AV.masterKey) {
116-
headers['X-LC-Sign'] = sign(AV.masterKey, true);
124+
if (signKey) {
125+
headers['X-LC-Sign'] = sign(AV.masterKey, true);
126+
} else {
127+
headers['X-LC-Key'] = `${AV.masterKey},master`;
128+
}
117129
} else {
118130
console.warn('masterKey is not set, fall back to use appKey');
119-
headers['X-LC-Sign'] = sign(AV.applicationKey);
131+
setAppId(headers, signKey);
120132
}
121133
} else {
122-
headers['X-LC-Sign'] = sign(AV.applicationKey);
134+
setAppId(headers, signKey);
123135
}
124136
if (AV._config.applicationProduction !== null) {
125137
headers['X-LC-Prod'] = AV._config.applicationProduction;

0 commit comments

Comments
 (0)