Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

496
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!