Skip to content

Commit

Permalink
add cors rust server
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulTrombin committed Dec 11, 2024
1 parent d2d547e commit 0dd64df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ thiserror = "1.0.63"
shellexpand = "3.1"

tauri = { version = "1.7.2", optional = true, features = ["shell-open"] }
actix-cors = "0.7.0"


[build-dependencies]
Expand Down
6 changes: 5 additions & 1 deletion src/server/manager.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::device::manager::ManagerActorHandler;

use super::protocols;
use actix_web::{middleware, web::Data, App, HttpServer};
use actix_cors::Cors;
use actix_web::{http, middleware, web::Data, App, HttpServer};
use tracing::info;

use paperclip::actix::{
Expand All @@ -18,11 +19,14 @@ pub async fn run(server_address: &str, handler: ManagerActorHandler) -> std::io:
info!("ServerManager: Service starting");

let server = HttpServer::new(move || {
let cors = Cors::permissive();

let v1 = add_v1_paths(web::scope("/v1"));
let default = add_v1_paths(web::scope(""));

App::new()
.app_data(Data::new(handler.clone()))
.wrap(cors)
.wrap(middleware::Logger::default())
.wrap_api()
.with_json_spec_at("/api/spec")
Expand Down

0 comments on commit 0dd64df

Please sign in to comment.