Skip to content

Commit

Permalink
fix: set cors header
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Feb 2, 2024
1 parent 88d3a17 commit b0cd195
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ serde_json = { workspace = true }
snmalloc-rs = "0.3"
tokio = { workspace = true }
tokio-graceful-shutdown = { workspace = true }
tower-http = { version = "0.4", features = ["fs", "trace"] }
tower-http = { version = "0.4", features = ["cors", "fs", "trace"] }
tracing = { workspace = true }
tracing-error = { workspace = true }
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
Expand Down
3 changes: 2 additions & 1 deletion src/subsystem/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use activitypub_federation::config::{FederationConfig, FederationMiddleware};
use axum::Router;
use hatsu_utils::{AppData, AppEnv, AppError};
use tokio_graceful_shutdown::SubsystemHandle;
use tower_http::{services::ServeDir, trace::TraceLayer};
use tower_http::{cors::CorsLayer, services::ServeDir, trace::TraceLayer};

use crate::routes;

Expand All @@ -20,6 +20,7 @@ impl Server {
let app = Router::new()
.merge(routes::handler())
.layer(FederationMiddleware::new(self.federation_config))
.layer(CorsLayer::permissive())
.layer(TraceLayer::new_for_http())
.fallback_service(ServeDir::new("assets"));

Expand Down

0 comments on commit b0cd195

Please sign in to comment.