mdouchement / standardfile

Yet Another Standardfile (standardnotes server) Implementation written in Golang
MIT License
80 stars 9 forks source link

config for the official web client #107

Closed cyberb closed 10 months ago

cyberb commented 10 months ago

Sorry this is not an issue but a question.

What is the best way to pre-configure the official web client (/) to use this backend (/api) when served under the same url?

I can see the client has this config by default: https://github.com/standardnotes/app/blob/main/packages/web/index.html

<body
  data-default-sync-server="<%= env.DEFAULT_SYNC_SERVER %>"
  data-default-files-host="<%= env.DEFAULT_FILES_HOST %>"
  data-enable-unfinished-features="<%= env.ENABLE_UNFINISHED_FEATURES %>"
  data-web-socket-url="<%= env.WEBSOCKET_URL %>"
  data-purchase-url="<%= env.PURCHASE_URL %>"
  data-plans-url="<%= env.PLANS_URL %>"
  data-dashboard-url="<%= env.DASHBOARD_URL %>"
  data-dev-account-email="<%= env.DEV_ACCOUNT_EMAIL %>"
  data-dev-account-password="<%= env.DEV_ACCOUNT_PASSWORD %>"
  data-dev-account-server="<%= env.DEV_ACCOUNT_SERVER %>"
  >
  <script>
    window.defaultSyncServer = document.body.dataset.defaultSyncServer || "https://api.standardnotes.com";
    window.defaultFilesHost = document.body.dataset.defaultFilesHost;
    window.enabledUnfinishedFeatures = document.body.dataset.enableUnfinishedFeatures === 'true';
    window.websocketUrl = document.body.dataset.webSocketUrl;
    window.purchaseUrl = document.body.dataset.purchaseUrl;
    window.plansUrl = document.body.dataset.plansUrl;
    window.dashboardUrl = document.body.dataset.dashboardUrl;
    window.devAccountEmail = document.body.dataset.devAccountEmail;
    window.devAccountPassword = document.body.dataset.devAccountPassword;
    window.devAccountServer = document.body.dataset.devAccountServer;
  </script>
</body>

which in runtime shows me this (I built it myself with no special env):

    <script>
      window.defaultSyncServer = "https://api.standardnotes.com";
      window.defaultFilesHost = "https://files.standardnotes.com";
      window.enabledUnfinishedFeatures = false;
      window.websocketUrl = "wss://sockets.standardnotes.com";
      window.purchaseUrl = "https://standardnotes.com/purchase";
      window.plansUrl = "https://standardnotes.com/plans";
      window.dashboardUrl = "https://standardnotes.com/dashboard";
    </script>
mdouchement commented 10 months ago

I convert it to a discussion.

To me <%= => pattern is a filled by a templating engine. But I don't know what server renders this HTML though.