diff --git a/actix/resources/js/main.js b/actix/resources/js/main.js index 1b9f754..48fdfa8 100644 --- a/actix/resources/js/main.js +++ b/actix/resources/js/main.js @@ -1,4 +1,4 @@ -const getSiteUrl = async () => await fetch("/api/site") +const getSiteUrl = async () => await fetch("/api/siteurl") .then(res => res.text()) .then(text => { if (text == "unset") { diff --git a/actix/src/main.rs b/actix/src/main.rs index 9197361..2b8f278 100644 --- a/actix/src/main.rs +++ b/actix/src/main.rs @@ -1,3 +1,5 @@ +use std::env; + use actix_files::{Files, NamedFile}; use actix_web::{ get, @@ -18,6 +20,14 @@ async fn getall() -> HttpResponse { HttpResponse::Ok().body(utils::getall()) } +// Get the site URL +#[get("/api/siteurl")] +async fn siteurl() -> HttpResponse { + let site_url = env::var("site_url").unwrap_or(String::from("unset")); + println!("{site_url}"); + HttpResponse::Ok().body(site_url) +} + // 404 error page #[get("/err/404")] async fn error404() -> impl Responder { @@ -42,6 +52,7 @@ async fn main() -> std::io::Result<()> { .service(link_handler) .service(error404) .service(getall) + .service(siteurl) .service(Files::new("/", "./resources/").index_file("index.html")) }) .bind(("0.0.0.0", 2000))? diff --git a/compose.yaml b/compose.yaml index 61f1af4..32dc91c 100644 --- a/compose.yaml +++ b/compose.yaml @@ -8,6 +8,7 @@ services: environment: # Change if you want to mount the database somewhere else # In this case, you can get rid of the db volume below + # and instead do a mount manually by specifying the location # - db_url=/urls.sqlite # Change it in case you want to set the website name # displayed in front of the shorturls, defaults to