Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

495
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda