Chrome WhatsApp Web无法在电子应用程序中工作(更新到谷歌浏览器)

7bsow1i6  于 2023-01-10  发布在  Go
关注(0)|答案(1)|浏览(193)

我不能运行whatsapp在我的电子浏览器上,即使设置useragent到最新的chrome版本如果有人有解决方案,请告诉

gab6jxml

gab6jxml1#

有必要删除:
响应标题=〉“X帧选项”
请求标头=〉“秒-获取-目的地”
我认为Whatsapp不允许iframe,因此您必须删除该信息才能使其正常工作
在主过程中

const mainWindow = new BrowserWindow({
    webPreferences: {
        nodeIntegration: true,
        contextIsolation: false,
    },
});

mainWindow.webContents.session.webRequest.onHeadersReceived(
{ urls: ['https://web.whatsapp.com/'] }, 
(details: any, callback) => {
    if (details && details.responseHeaders['X-Frame-Options']) {
        delete details.responseHeaders['X-Frame-Options'];
    } else if (details.responseHeaders['x-frame-options']) {
        delete details.responseHeaders['x-frame-options'];
    }
    callback({ cancel: false, responseHeaders: details.responseHeaders });
});

mainWindow.webContents.session.webRequest.onBeforeSendHeaders(
{ urls: ['https://web.whatsapp.com/'] },
(details, callback) => {
    details.requestHeaders['User-Agent'] = userAgent;
    details.requestHeaders['Access-Control-Allow-Origin'] = '*';
    if (details.requestHeaders['Sec-Fetch-Dest']) {
        delete details.requestHeaders['Sec-Fetch-Dest'];
    }
    callback({ cancel: false, requestHeaders: details.requestHeaders });
});

在远程进程中

<iframe src="https://web.whatsapp.com/"  />

相关问题