Skip to content

Commit

Permalink
use DEV_BUILD const
Browse files Browse the repository at this point in the history
  • Loading branch information
fairingrey committed Feb 19, 2022
1 parent 8e7bb03 commit 16b6e52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ pub(crate) mod handlers;
pub(crate) mod server;
pub(crate) mod utils;

pub(crate) const DEV_BUILD: bool = cfg!(debug_assertions);

#[tokio::main]
async fn main() -> Result<(), anyhow::Result<()>> {
if cfg!(debug_assertions) {
if DEV_BUILD {
dotenv::dotenv().ok();
} else {
dotenv::from_filename("prod.env").ok();
Expand Down
2 changes: 1 addition & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl State {
fn try_cors_layer() -> Result<CorsLayer> {
use axum::http::Method;

if cfg!(debug_assertions) {
if crate::DEV_BUILD {
Ok(CorsLayer::permissive())
} else {
let origins = std::env::var("ALLOWED_ORIGINS")?
Expand Down

0 comments on commit 16b6e52

Please sign in to comment.