summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--index.html7
-rw-r--r--src/lib.rs20
2 files changed, 25 insertions, 2 deletions
diff --git a/index.html b/index.html
index 3772400..303ca24 100644
--- a/index.html
+++ b/index.html
@@ -15,6 +15,13 @@
       data-weak-refs
     />
 
+    <div id="location-storage" location="localhost"></div>
+    <script>
+        document
+            .querySelector("div#location-storage")
+            .setAttribute("location", document.location.href);
+    </script>
+
     <link
       data-trunk
       rel="icon"
diff --git a/src/lib.rs b/src/lib.rs
index a884201..45f6e90 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -21,12 +21,16 @@ mod api;
 mod components;
 mod pages;
 
-use leptos::prelude::{AddAnyAttr, IntoView, component, provide_context, view};
+use leptos::{
+    prelude::{AddAnyAttr, IntoView, component, provide_context, view},
+    tachys::dom::document,
+};
 use leptos_meta::{Html, Meta, Title, provide_meta_context};
 use leptos_router::{
     components::{Route, Router, Routes},
     path,
 };
+use log::error;
 use reactive_stores::Store;
 use rocie_client::apis::configuration::Configuration;
 
@@ -52,7 +56,19 @@ pub fn App() -> impl IntoView {
         let mut config = Configuration::new();
 
         config.user_agent = Some("rocie-mobile".to_owned());
-        "/api/".clone_into(&mut config.base_path);
+
+        let document = document();
+        format!(
+            "{}/api",
+            document
+                .query_selector("div#location-storage")
+                .expect("This part is defined in the index.html")
+                .expect("This part is really defined in the index.html")
+                .get_attribute("location")
+                .expect("This was set in the index.html")
+                .trim_end_matches('/')
+        )
+        .clone_into(&mut config.base_path);
 
         config
     };