Skip to content

Commit

Permalink
Allow cross-origin requests
Browse files Browse the repository at this point in the history
Co-authored-by: diamondburned <diamond@arikawa-hi.me>
  • Loading branch information
diamondburned committed Jun 30, 2023
1 parent 3159eed commit 0f51468
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,12 @@ pub async fn start_lemmy_server() -> Result<(), LemmyError> {

// Create Http server with websocket support
HttpServer::new(move || {
let cors_config = if cfg!(debug_assertions) {
Cors::permissive()
} else {
let cors_origin = std::env::var("LEMMY_CORS_ORIGIN").unwrap_or("http://localhost".into());
Cors::default()
.allowed_origin(&cors_origin)
.allowed_origin(&settings.get_protocol_and_hostname())
};
let cors_config = Cors::default()
.allow_any_origin()
.allow_any_method()
.allow_any_header()
.expose_any_header()
.max_age(3600);

App::new()
.wrap(middleware::Logger::new(
Expand Down

0 comments on commit 0f51468

Please sign in to comment.