Skip to content
Merged
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
24 changes: 11 additions & 13 deletions desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ _.assign(console, log.functions);
// until it detects that it has been upgraded to the correct version.

const EXPECTED_UPDATE_VERSION_FLAG = '--expected-update-version';
const APP_DOMAIN = __DEV__ ? `http://localhost:${port}` : 'app://*';

let expectedUpdateVersion;
for (let i = 0; i < process.argv.length; i++) {
Expand Down Expand Up @@ -160,19 +159,18 @@ const mainWindow = (() => {
details.requestHeaders.referer = CONFIG.EXPENSIFY.URL_EXPENSIFY_CASH;
callback({requestHeaders: details.requestHeaders});
});
}

// Modify access-control-allow-origin header and CSP for the response
webRequest.onHeadersReceived(validDestinationFilters, (details, callback) => {
details.responseHeaders['access-control-allow-origin'] = [APP_DOMAIN];
if (details.responseHeaders['content-security-policy']) {
details.responseHeaders['content-security-policy'] = _.map(
details.responseHeaders['content-security-policy'],
value => (value.startsWith('frame-ancestors') ? `${value} ${APP_DOMAIN}` : value),
);
}
callback({responseHeaders: details.responseHeaders});
});
// Modify access-control-allow-origin header for the response
webRequest.onHeadersReceived(validDestinationFilters, (details, callback) => {
details.responseHeaders['access-control-allow-origin'] = ['app://-'];
callback({responseHeaders: details.responseHeaders});
});
} else {
webRequest.onHeadersReceived(validDestinationFilters, (details, callback) => {
details.responseHeaders['access-control-allow-origin'] = [`http://localhost:${process.env.PORT}`];
callback({responseHeaders: details.responseHeaders});
});
}
/* eslint-enable */

// Prod and staging overwrite the app name in the electron-builder config, so only update it here for dev
Expand Down