Skip to content
Advertisement

apis delcared in contextbridge undefined in render process

I’ve been working on updating a electron app from 11.x to 12.x and have run into an issue where the apis declared by contextBridge.exposeInMainWorld come as undefined when called upon through window.

This is my preload.js file

JavaScript

my app.js

JavaScript

I’m lost on why contextBridge doesn’t work.

Advertisement

Answer

The object passed to the BrowserWindow constructor is not correct. The preload option should be a property of webPreferences

JavaScript

See the docs

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement