Skip to content

Commit bcd49c3

Browse files
authored
Merge pull request #8333 from mook-as/electron-35/preload
RDX: Update preload script loading
2 parents c9efe0c + 2ad5bce commit bcd49c3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/rancher-desktop/window/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,20 @@ function createView() {
211211
const webPreferences: Electron.WebPreferences = {
212212
nodeIntegration: false,
213213
contextIsolation: true,
214-
preload: path.join(paths.resources, 'preload.js'),
215214
sandbox: true,
216215
additionalArguments: [JSON.stringify(hostInfo)],
217216
};
218217

219218
if (currentExtension?.id) {
220219
webPreferences.partition = `persist:rdx-${ currentExtension.id }`;
221-
const webRequest = Electron.session.fromPartition(webPreferences.partition).webRequest;
220+
const session = Electron.session.fromPartition(webPreferences.partition);
221+
const { webRequest } = session;
222+
223+
session.registerPreloadScript({
224+
id: `rdx-preload-${ currentExtension.id }`,
225+
filePath: path.join(paths.resources, 'preload.js'),
226+
type: 'frame',
227+
});
222228

223229
webRequest.onBeforeSendHeaders((details, callback) => {
224230
const source = details.webContents?.getURL() ?? '';

0 commit comments

Comments
 (0)