diff --git a/Cargo.toml b/Cargo.toml index 3f08b71..3bde751 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,7 @@ sea-orm-migration = { version = "0.12", optional = true } # mastodon mastodon-async-entities = { version = "1.1.0", optional = true } time = { version = "0.3", features = ["serde"], optional = true } +tower-http = { version = "0.5.2", features = ["cors", "trace"] } [features] default = ["faker", "migrations", "mastodon"] diff --git a/src/main.rs b/src/main.rs index 95aa4e8..4204594 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,7 @@ use clap::{Parser, Subcommand}; use sea_orm::{ConnectOptions, Database, EntityTrait, IntoActiveModel}; pub use errors::UpubResult as Result; +use tower_http::{cors::CorsLayer, trace::TraceLayer}; use crate::server::fetcher::Fetchable; @@ -107,6 +108,8 @@ async fn main() { let router = axum::Router::new() .ap_routes() .mastodon_routes() // no-op if mastodon feature is disabled + .layer(CorsLayer::permissive()) + .layer(TraceLayer::new_for_http()) .with_state(ctx); // run our app with hyper, listening locally on port 3000