Closed hugomano closed 5 years ago
CORS workaround for the next PR
const filter = {
urls: [
'https://*.google.com/mail/u/0/*', 'chrome-extension://dheionainndbbpoacpnopgmnihkcmnkl'
],
}
session.webRequest.onBeforeSendHeaders(filter, (details, callback) => {
console.log(details);
callback({ cancel: false, requestHeaders: details.requestHeaders });
})
Sample example of how disable cors
const filter = {
urls: ['https://compose.mixmax.com/api/views/*']
}
session.webRequest.onHeadersReceived(filter, (details, callback) => {
if (details.resourceType === 'xhr') {
const { protocol, hostname, pathname } = new URL(details.url)
const responseHeaders = details.responseHeaders
const requestHeaders = details.headers
const updatedHeaders = {
...responseHeaders,
'access-control-allow-credentials': responseHeaders['access-control-allow-credentials'] || ['true'],
'access-control-allow-headers': [].concat(
responseHeaders['access-control-allow-headers'],
requestHeaders['Access-Control-Request-Headers'],
Object.keys(requestHeaders).filter((k) => k.startsWith('X-'))
),
'Access-Control-Allow-Origin': [
`chrome-extension://ocpljaamllnldhepankaeljmeeeghnid`
]
}
console.log("updatedHeaders l1: ", details);
console.log("updatedHeaders l2: ", updatedHeaders);
return callback({ cancel: false, responseHeaders: updatedHeaders })
}
})
session.webRequest.onBeforeSendHeaders(filter, (details, callback) => {
if (details.resourceType === 'xhr') {
const a = {
...details.requestHeaders,
'Origin': ['null']
}
callback({ cancel: false, requestHeaders: a })
}
})
v2.0.0
tov3.0.4
OLD_README.md
for nowelectron-chrome-extension
tochrome-extension
schemechrome.storage
API⚠️ Squash this PR