Skip to content

Build your personal knowledge base with Trilium Notes

fix(edit-docs): not starting up due to protocol init

Elian Doran733849a7b02e
diff --git a/apps/edit-docs/src/utils.ts b/apps/edit-docs/src/utils.ts
index 5bd1e5bcb2..2d9ee22378 100644
--- a/apps/edit-docs/src/utils.ts
+++ b/apps/edit-docs/src/utils.ts
@@ -14,6 +14,25 @@ import path from "path";
import { deferred, type DeferredPromise } from "../../../packages/commons/src/index.js";
+// The renderer loads the entire UI from `trilium-app://app/` (see
+// apps/server/src/services/window.ts). The scheme has to be registered as
+// privileged before `app.ready` fires; otherwise Chromium treats it as a
+// non-standard scheme with an opaque origin and blocks the navigation with
+// `(blocked:origin)`. Desktop does the same in apps/desktop/src/main.ts. This
+// runs at module top-level so it executes during the import phase of
+// edit-docs.ts / edit-demo.ts, before either entry point's first `await`.
+electron.protocol.registerSchemesAsPrivileged([
+ {
+ scheme: "trilium-app",
+ privileges: {
+ standard: true,
+ secure: true,
+ supportFetchAPI: true,
+ corsEnabled: true
+ }
+ }
+]);
+
// Stub backup service (not used in edit-docs, but required by initializeCore)
class StubBackupService extends BackupService {
constructor() {