Skip to content

Commit

Permalink
Merge pull request #66 from everpcpc/fix-cors
Browse files Browse the repository at this point in the history
fix: more cors settings
  • Loading branch information
BohuTANG authored May 19, 2023
2 parents d8b7a2b + 4ee0141 commit 6272e47
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/src/api/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

use actix_cors::Cors;
use actix_web::http;
use actix_web::web;
use actix_web::App;
use actix_web::HttpServer;
Expand Down Expand Up @@ -43,7 +44,14 @@ impl APIHandler {
let data = self.db.clone();

HttpServer::new(move || {
let mut cors = Cors::default();
let mut cors = Cors::default()
.allowed_methods(vec!["GET", "POST"])
.allowed_headers(vec![
http::header::AUTHORIZATION,
http::header::ACCEPT,
http::header::CONTENT_TYPE,
])
.max_age(3600);
for origin in &conf.cors {
cors = cors.allowed_origin(origin);
}
Expand Down

1 comment on commit 6272e47

@vercel
Copy link

@vercel vercel bot commented on 6272e47 May 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.