Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

497
Visualizações
Cordova-Electron : Is there a way to add preload.js script and disable node-integration?

In the Apache Cordova doc (https://cordova.apache.org/docs/en/10.x/guide/platforms/electron/index.html), it is suggested to set "nodeIntegration" to true in settings.json file to use NodeJs and Electron API in the renderer part of my app. However, in the electron doc, this action is not recommended for security reasons, and it is suggested to use a preload script to do so.

Is it possible to do the same with cordova-electron ? Something like this doesn't seems to work :

{
"browserWindow": {
    "width": 1024,
    "height": 768,
    "fullscreen": false,
    "frame": false,
    "webPreferences": {
        "nodeIntegration": false,
        "preload": "file://{Directory}/preload.js",
        "contextIsolation": true
    }
}

The "preload" option isn't read. I'm using cordova 10, with cordova-electron 2.0.

Thanks in advance for any advice. :)

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

According to the Electron documentation we have to use absolute path for the preload and file:// protocol is considered as a non-absolute. If you change the path to a really absolute one the app will try to preload it. The problem here is defining dynamic path in that json configuration. As far as I can see it couldn't be set using __dirname directive, so the easiest way at least for now is using nodeIntergration: true in cordova-electron build

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda