diff --git a/docker/prod.yml b/docker/prod.yml index 99b0ee2..8098717 100644 --- a/docker/prod.yml +++ b/docker/prod.yml @@ -3,4 +3,4 @@ services: track-server: image: us-central1-docker.pkg.dev/hubs-dev-333333/ocho-osai/johnshaughnessy/track/track-server volumes: - - ./track:/track + - ./:/track diff --git a/server/src/api/weights.rs b/server/src/api/weights.rs index 0372225..82fdc96 100644 --- a/server/src/api/weights.rs +++ b/server/src/api/weights.rs @@ -16,14 +16,14 @@ pub async fn post_weights( } pub async fn get_weights(pool: web::Data>>) -> impl Responder { + log::info!("get_weights"); let mut conn = pool.get().unwrap(); match server::models::weights::read_weights(&mut conn) { Ok(weights) => HttpResponse::Ok().json(weights), Err(e) => { HttpResponse::InternalServerError().body(format!("Error retrieving weights: {:?}", e)) - } - // Err(_) => HttpResponse::InternalServerError().body("Error retrieving weights."), + } // Err(_) => HttpResponse::InternalServerError().body("Error retrieving weights."), } } diff --git a/server/src/main.rs b/server/src/main.rs index daa0e35..dffc258 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -34,7 +34,7 @@ async fn main() -> std::io::Result<()> { .allowed_header(http::header::CONTENT_TYPE) .max_age(3600), ref x if x == "prod" => Cors::default() - .allowed_origin("https://www.example.com") + .allow_any_origin() .allowed_methods(vec!["GET", "POST", "PATCH", "DELETE"]) .allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT]) .allowed_header(http::header::CONTENT_TYPE) @@ -42,26 +42,26 @@ async fn main() -> std::io::Result<()> { _ => panic!("APP_ENV must be set to either 'dev' or 'prod'"), }; - println!("APP_ENV: {:?}", std::env::var("APP_ENV")); - println!("cors: {:?}", cors); + log::info!("APP_ENV: {:?}", std::env::var("APP_ENV")); + log::info!("cors: {:?}", cors); App::new() .wrap(cors) .app_data(web::Data::new(pool.clone())) - .service(fs::Files::new("/", "/track/server/static/client/").index_file("index.html")) .service( web::scope("/api") - .service( - web::resource("/weights") - .route(web::get().to(api::get_weights)) - .route(web::post().to(api::post_weights)), - ) .service( web::resource("/weights/{weight_id}") .route(web::patch().to(api::patch_weights)) .route(web::delete().to(api::delete_weights)), + ) + .service( + web::resource("/weights") + .route(web::get().to(api::get_weights)) + .route(web::post().to(api::post_weights)), ), ) + .service(fs::Files::new("/", "/track/server/static/client/").index_file("index.html")) }) .bind(format!("{}:{}", ip_address, port))? .run()