Skip to content

Commit

Permalink
Cors fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Loudbooks committed Dec 10, 2024
1 parent d2d6183 commit 4792ebd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
16 changes: 16 additions & 0 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"

[dependencies]
actix-web = "4"
actix-cors = "0.7.0"
mongodb = "3.1.0"
aws-sdk-s3 = { version = "1.65.0" }
tokio = { version = "1", features = ["full"] }
Expand Down
15 changes: 6 additions & 9 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use actix_web::{web, App, HttpResponse, HttpServer, Responder};
use dotenv::dotenv;
use std::env;
use std::sync::Arc;
use aws_sdk_s3::types::builders::CorsRuleBuilder;
use actix_cors::Cors;

#[actix_web::main]
async fn main() -> std::io::Result<()> {
Expand Down Expand Up @@ -52,15 +52,12 @@ async fn main() -> std::io::Result<()> {

let delete_handler = DeleteHandler::new(Arc::clone(&aws_service), Arc::clone(&mongo_service));
delete_handler.start_delete_loop();

let cors = CorsRuleBuilder::default()
.allowed_origins(vec!["*"])
.allowed_methods(vec!["GET", "POST"])
.allowed_headers(vec!["*"])
.build();


HttpServer::new(move || {
App::new().wrap(cors)
let cors = Cors::permissive();

App::new()
.wrap(cors)
.app_data(web::Data::new(Arc::clone(&aws_service)))
.app_data(web::Data::new(Arc::clone(&mongo_service)))
.route("/get/{id}/content", web::get().to(get_content_handler))
Expand Down

0 comments on commit 4792ebd

Please sign in to comment.