pareshm
pareshm

Reputation: 4984

Avoid writing Cookies in file in case of MAC in electron

The following code is used to load my application. When the URL is accessed, an API call is made that attempts to set cookies, such as session_id. On macOS (DARWIN), Electron creates a cookies file to store the session_id. However, I do not want this behavior. I tried deleting the file through code, but the application fails to run without the session_id.

Can you suggest a solution to avoid this?

Below are the versions I am using "electron": "32.0.1", "electron-packager": "17.1.1"

and Code is written in ReactJS

Thanks in advance..

Below is my code

// Module to control application life.
const remoteMain = require('@electron/remote/main')
remoteMain.initialize()
const app = electron.app;
const Menu = electron.Menu;

app.commandLine.appendSwitch('--no-proxy-server');

const os = require('os');
const fs = require('fs');

// This is remove "Start Dictation" sub-menu from edit menu in MacOS
if( os.platform() == 'darwin' ){
    const systemPreferences = electron.systemPreferences;
    systemPreferences.setUserDefault('NSDisabledDictationMenuItem', 'boolean', true);
}

// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow

const path = require('path')
const url = require('url')
const {spawn} = require('child_process');

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
let windowType
const createWindow = () => {
if (windowType === 'main') {
        if(!isNum(clientApiServerPort))
            return;

        var num = parseInt(clientApiServerPort)
        if(!checkIfValidPortnumber(num))
            return;

        port = '' + clientApiServerPort;
        inSyncURL = 'http://127.0.0.1:' + port + '/index.html';
        w = 800;
        h = 490;
mainWindow = new BrowserWindow(
        {
            show: true,
            width: w,
            height: h,
            resizable:false,
            maximizable:false,
            fullscreen: false,
            center:true,
            fullscreenable: false,
            title:"Druva inSync",
            webPreferences: {
                nodeIntegration: true,
                webviewTag: true,
                enableRemoteModule: true,
                contextIsolation: false
            }
        }
    )}
}
app.on('ready', createWindow);

Upvotes: 0

Views: 16

Answers (0)

Related Questions