Skip to content

Commit

Permalink
fix: remove origin header from background requests
Browse files Browse the repository at this point in the history
  • Loading branch information
dessant committed Feb 2, 2020
1 parent a57cdb8 commit 999ccf9
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
ibmSpeechApiUrls,
microsoftSpeechApiUrls
} from 'utils/data';
import {clientAppVersion, witApiKeys} from 'utils/config';
import {targetEnv, clientAppVersion, witApiKeys} from 'utils/config';

let nativePort;

Expand Down Expand Up @@ -170,27 +170,27 @@ function addBackgroundRequestLitener() {
'https://www.google.com/*',
'https://api.wit.ai/*',
'https://speech.googleapis.com/*',
'https://stream-fra.watsonplatform.net/*',
'https://stream.watsonplatform.net/*',
'https://gateway-wdc.watsonplatform.net/*',
'https://gateway-syd.watsonplatform.net/*',
'https://gateway-tok.watsonplatform.net/*',
'https://eastus.stt.speech.microsoft.com/*',
'https://westus.stt.speech.microsoft.com/*',
'https://westus2.stt.speech.microsoft.com/*',
'https://eastasia.stt.speech.microsoft.com/*',
'https://southeastasia.stt.speech.microsoft.com/*',
'https://westeurope.stt.speech.microsoft.com/*',
'https://northeurope.stt.speech.microsoft.com/*'
'https://*.speech-to-text.watson.cloud.ibm.com/*',
'https://*.stt.speech.microsoft.com/*'
];

const extraInfo = ['blocking', 'requestHeaders'];
if (
targetEnv !== 'firefox' &&
Object.values(browser.webRequest.OnBeforeSendHeadersOptions).includes(
'extraHeaders'
)
) {
extraInfo.push('extraHeaders');
}

browser.webRequest.onBeforeSendHeaders.addListener(
removeRequestOrigin,
{
urls,
types: ['xmlhttprequest']
},
['blocking', 'requestHeaders']
extraInfo
);
}
}
Expand Down Expand Up @@ -462,7 +462,7 @@ async function onMessage(request, sender) {
} else if (request.id === 'transcribeAudio') {
addBackgroundRequestLitener();
try {
return transcribeAudio(request.audioUrl, request.lang);
return await transcribeAudio(request.audioUrl, request.lang);
} finally {
removeBackgroundRequestLitener();
}
Expand Down

0 comments on commit 999ccf9

Please sign in to comment.