diff --git a/frontend/index.html b/frontend/index.html
index b834550..4768a8e 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -5,6 +5,7 @@
     <meta name="viewport" content="width=device-width, initial-scale=1" />
     <title>Peazyweb - OpenVPN config creator</title>
     <script src="https://cdn.tailwindcss.com"></script>
+    <base data-trunk-public-url />
   </head>
   <body class="bg-gradient-to-r from-[#f0f9ff] to-[#e6f3ff]">
     <div id="app"></div>
@@ -13,4 +14,4 @@
       init();
     </script>
   </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/frontend/src/main.rs b/frontend/src/main.rs
index 52750f3..21b0512 100644
--- a/frontend/src/main.rs
+++ b/frontend/src/main.rs
@@ -37,8 +37,15 @@ pub enum Route {
 }
 
 lazy_static! {
-    static ref API_BASE_URL: String =
-        std::env::var("API_BASE_URL").unwrap_or("http://127.0.0.1:8000/api/v1".into());
+    static ref API_BASE_URL: String = option_env!("API_BASE_URL")
+        .unwrap_or(
+            (option_env!("TRUNK_PUBLIC_URL")
+                .unwrap_or("http://127.0.0.1:8000/")
+                .to_string()
+                + "api/v1")
+                .as_str(),
+        )
+        .to_owned();
 }
 
 pub struct APIEndpoints {}