about summary refs log tree commit diff
path: root/frontend
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2022-11-05 18:28:20 +0100
committerBaitinq <manuelpalenzuelamerino@gmail.com>2022-11-05 18:28:22 +0100
commit6d729376031e5d63bb4bc761f9d14d4f972e0793 (patch)
tree1fb0a40e40a337981b3317c48349d8243abababf /frontend
parentIndexer: Hold indexer lock for less time when in search endpoint (diff)
downloadOSSE-6d729376031e5d63bb4bc761f9d14d4f972e0793.tar.gz
OSSE-6d729376031e5d63bb4bc761f9d14d4f972e0793.tar.bz2
OSSE-6d729376031e5d63bb4bc761f9d14d4f972e0793.zip
Indexer: Switch back to not serving frontend with actix
This previously caused the frontend to be unresponsive when the crawler
was passing results to the indexer. Now the frontend is again
independently served by trunk and the api by actix, which makes them
separate processes and the frontend can remain responsive.
Diffstat (limited to 'frontend')
-rw-r--r--frontend/src/main.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/frontend/src/main.rs b/frontend/src/main.rs
index 29bdd71..e449e4a 100644
--- a/frontend/src/main.rs
+++ b/frontend/src/main.rs
@@ -1,6 +1,7 @@
 mod app;
 
 use app::OSSE;
+use web_sys::window;
 use yew::prelude::*;
 use yew_router::prelude::*;
 
@@ -15,12 +16,19 @@ enum Route {
 }
 
 fn switch_routes(routes: Route) -> Html {
+    let location = window().unwrap().location();
+    let api_endpoint = format!(
+        "{}//{}:{}/api",
+        location.protocol().unwrap(),
+        location.hostname().unwrap(),
+        4444
+    );
     match routes {
         Route::OSSEHome | Route::OSSEHomeEmptySearch => html! {
-            <OSSE api_endpoint={"/api"} initial_search_query={None as Option<String>} />
+            <OSSE api_endpoint={api_endpoint} initial_search_query={None as Option<String>} />
         },
         Route::OSSESearch { query } => html! {
-            <OSSE api_endpoint={"/api"} initial_search_query={Some(query)} />
+            <OSSE api_endpoint={api_endpoint} initial_search_query={Some(query)} />
         },
     }
 }