From dbd7454fbe2f530d68e5f2f9b9fd1c5b4798af81 Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Wed, 14 Jun 2017 11:10:05 +0200
Subject: [PATCH] [fix] Modules must be accessed through a sub-route "/modules"

---
 app/js/app.config.js | 11 +++++++++++
 index.js             |  4 +++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/app/js/app.config.js b/app/js/app.config.js
index ae5f6d8..fefb4b3 100644
--- a/app/js/app.config.js
+++ b/app/js/app.config.js
@@ -60,6 +60,17 @@ module.exports = () => {
     }
   };
 
+  window.openModule = function openWindow(path, options, callback) {
+    const url = window.location.origin + '/modules' + path
+    if (window.gui) {
+      // Duniter Desktop
+      window.gui.Window.open(url, options, callback);
+    } else {
+      // Browser
+      window.open(url, '_blank ');
+    }
+  };
+
   window.openExternal = function openExternal(url) {
     if (window.gui) {
       window.gui.Shell.openExternal(url);
diff --git a/index.js b/index.js
index 30a29e7..faed8ca 100644
--- a/index.js
+++ b/index.js
@@ -89,7 +89,9 @@ module.exports = {
           for (const dep of uiDeps) {
             // Eventual HTTP routing
             if (dep.required.duniterUI.route) {
-              dep.required.duniterUI.route(app, server, conf, program, params)
+              const subApp = express()
+              dep.required.duniterUI.route(subApp, server, conf, program, params)
+              app.use('/modules/', subApp)
             }
           }
 
-- 
GitLab