Cannot read properties of undefined: reading 'registerSchemesAsPrivileged'
jogibear9988 opened this issue · 2 comments
My new code looks this:
let win
let { app, protocol, BrowserWindow } = require('@electron/remote/main');
const fs = require("fs");
const path = require('path');
let { URL } = require("url");
require('@electron/remote/main').initialize()
const checkImportRegex = /(import|export)(\s*{?\*?[\s\w,$]*}?\s*(as)?[\s\w]*from\s|[\s]*)['\"]([^\.\/][\w\/\-@.]*?)['\"]/g;
let checkRelativeImportRegex = new RegExp("(import|export)(\\s*{?\\*?[\\s\\w,$]*}?\\s*(as)?[\\s\\w]*from\\s|[\\s]*)['\\\"]([\\.\\/][\\w\\/\\-@.]*?)['\\\"]", 'g');
protocol.registerSchemesAsPrivileged([{scheme: 'app', privileges: { secure: true, standard: true } }]);
let createProtocol = (scheme, normalize = true) => {
protocol.registerBufferProtocol(scheme,
async (request, respond) => {
....
Hey @jogibear9988,
I haven't tested the code but it looks like the issue is that you're using protocol
before the ready event of the app module gets emitted. I believe protocol
here is re-exported from Electron and the Electron docs say the protocol module can only be used after ready.
Marking as a question for clarification. If you're already waiting for ready, could you please upload a small test case as a gist and link to it here?
no, if you call it in ready you get this error:
(node:42568) UnhandledPromiseRejectionWarning: Error: protocol.registerSchemesAsPrivileged should be called before app is ready
butt i did it complety wrong, i changed the electron backend, but this is for the frontend part... shame on me