Skip to content

Commit

Permalink
Update constants.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
happy-machine authored Jan 23, 2023
1 parent 0d9ed45 commit 301e30e
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/config/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ pub struct Env {
fn create_url() -> String {
let port = env::var("GRAPHQL_PORT").unwrap_or("8000".to_string());
let rust_env = env::var("RUST_ENV").unwrap_or("development".to_string());
match env::var("GRAPHQL_HOST"){
Ok(v) => {
if v == "localhost".to_string() && rust_env == "production".to_string() {
return format!("0.0.0.0:{}", port);
} else if v == "localhost".to_string() {
return format!("127.0.0.1:{}", port);
} else {
return v;
}
},
Err(e) => return format!("127.0.0.1:{}", port),
let graphql_host = env::var("GRAPHQL_HOST").unwrap_or("localhost".to_string())
if graphql_host == "localhost".to_string() && rust_env == "production".to_string() {
return format!("0.0.0.0:{}", port);
} else if v == "localhost".to_string() {
return format!("127.0.0.1:{}", port);
} else {
return v;
}
}

Expand Down

0 comments on commit 301e30e

Please sign in to comment.