arami21 commited on
Commit
f16e764
·
verified ·
1 Parent(s): a29db50

Update src/main.rs

Browse files
Files changed (1) hide show
  1. src/main.rs +9 -1
src/main.rs CHANGED
@@ -2,6 +2,7 @@ use actix_cors::Cors;
2
  use actix_web::{web, App, HttpResponse, HttpServer};
3
  use confik::{Configuration as _, EnvSource};
4
  use dotenvy::dotenv;
 
5
 
6
  mod config;
7
  mod db;
@@ -46,9 +47,16 @@ async fn main() -> std::io::Result<()> {
46
 
47
  let supabase = Supabase::new(cfg.supabase_url, cfg.supabase_anon_key);
48
 
 
 
 
 
 
 
 
49
  HttpServer::new(move || {
50
  App::new()
51
- .wrap(Cors::permissive())
52
  .app_data(web::Data::new(supabase.clone()))
53
  .route("/health", web::get().to(health))
54
  .route("/guests/{slug}", web::get().to(get_guest))
 
2
  use actix_web::{web, App, HttpResponse, HttpServer};
3
  use confik::{Configuration as _, EnvSource};
4
  use dotenvy::dotenv;
5
+ use actix_cors::Cors;
6
 
7
  mod config;
8
  mod db;
 
47
 
48
  let supabase = Supabase::new(cfg.supabase_url, cfg.supabase_anon_key);
49
 
50
+ let cors = Cors::default()
51
+ .allowed_origin("https://arami21-space.github.io")
52
+ .allowed_methods(vec!["GET", "POST"])
53
+ .allowed_headers(vec!["Content-Type", "Authorization"])
54
+ .max_age(3600);
55
+
56
+
57
  HttpServer::new(move || {
58
  App::new()
59
+ .wrap(cors)
60
  .app_data(web::Data::new(supabase.clone()))
61
  .route("/health", web::get().to(health))
62
  .route("/guests/{slug}", web::get().to(get_guest))