diff --git a/Cargo.lock b/Cargo.lock index f2c1270..772b8b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,6 +19,21 @@ dependencies = [ "tracing", ] +[[package]] +name = "actix-cors" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b340e9cfa5b08690aae90fb61beb44e9b06f44fe3d0f93781aaa58cfba86245e" +dependencies = [ + "actix-utils", + "actix-web", + "derive_more", + "futures-util", + "log", + "once_cell", + "smallvec", +] + [[package]] name = "actix-http" version = "3.4.0" @@ -284,6 +299,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" name = "bible-api" version = "0.1.0" dependencies = [ + "actix-cors", "actix-web", "dotenvy", "env_logger", diff --git a/Cargo.toml b/Cargo.toml index 5e4597a..386851f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +actix-cors = "0.6.4" actix-web = "4.4.0" dotenvy = "0.15.7" env_logger = "0.10.0" diff --git a/src/main.rs b/src/main.rs index 8e06386..6f6e678 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; use serde_json::json; use sqlx::postgres::{PgPool, PgPoolOptions}; use sqlx::FromRow; +use actix_cors::Cors; #[derive(Debug, Clone)] struct AppData { @@ -223,6 +224,7 @@ async fn main() -> std::io::Result<()> { env_logger::init(); let server = HttpServer::new(move || { App::new() + .wrap(Cors::permissive()) .wrap(Logger::default()) .app_data(web::Data::new(app_data.clone())) .service(home)