Search code examples
electrondocusaurus

Custom protocol for Docusaurus


We want to serve a Docusaurus-build with Electron.

For this we are using a custom protocol that just serves the files to the Electron-Browser.

The Problem is, the Javascript that is running in the static-html build of the Docusaurus app just wont accept the url (at least that is what we think)

If we serve "doc://doc/docs/intro/index.html" it pops up for a second and afterwards the "Page Not Found"-page is shown - because the javascript does that.

Our url is "doc://doc" and our baseUrl is "/" and we can not figure out how to stop the Javascript from chaning the currently loaded page to the Page not found one.

(We disabled the Javascript and if it is disabled that error does not appear)


Solution

  • The problem was Electron...

    You have to give the custom protocol privledge with this:

    protocol.registerSchemesAsPrivileged([
      {
        scheme: 'doc',
        privileges: { secure: true, standard: true },
      },
    ]);
    

    So it has actually nothing to do with Docusaurus.