@@ -8,12 +8,16 @@ use queensac::{cancel_repository_checker, check_repository_links, stream_link_ch
88use axum:: {
99 Json , Router ,
1010 extract:: { Query , State } ,
11- http:: StatusCode ,
11+ http:: {
12+ HeaderValue , Method , StatusCode ,
13+ header:: { ACCEPT , AUTHORIZATION , CONTENT_TYPE } ,
14+ } ,
1215 routing:: { delete, get, post} ,
1316} ;
1417use sqlx:: PgPool ;
1518use std:: sync:: Arc ;
1619use std:: time:: Duration ;
20+ use tower_http:: cors:: CorsLayer ;
1721use tracing:: { Level , error, info} ;
1822use tracing_subscriber:: FmtSubscriber ;
1923
@@ -122,8 +126,7 @@ async fn main(#[shuttle_shared_db::Postgres] pool: PgPool) -> shuttle_axum::Shut
122126 . pretty ( )
123127 . init ( ) ;
124128
125- info ! ( "Starting Queensac service..." ) ;
126-
129+ info ! ( "Starting queensac service..." ) ;
127130 dotenvy:: dotenv ( ) . ok ( ) ;
128131
129132 // 이메일 클라이언트 설정 로드
@@ -154,11 +157,21 @@ async fn main(#[shuttle_shared_db::Postgres] pool: PgPool) -> shuttle_axum::Shut
154157}
155158
156159fn app ( pool : PgPool , email_client : Arc < EmailClient > ) -> Router {
160+ let cors = CorsLayer :: new ( )
161+ . allow_origin ( [
162+ HeaderValue :: from_static ( "https://redddy.com" ) ,
163+ HeaderValue :: from_static ( "https://www.redddy.com" ) ,
164+ ] )
165+ . allow_methods ( [ Method :: GET , Method :: POST , Method :: DELETE , Method :: OPTIONS ] )
166+ . allow_headers ( [ CONTENT_TYPE , AUTHORIZATION , ACCEPT ] )
167+ . allow_credentials ( true ) ;
168+
157169 Router :: new ( )
158170 . route ( "/" , get ( || async { "Sacrifice the Queen!!" } ) )
159171 . route ( "/health" , get ( health_check) )
160172 . route ( "/check" , post ( check_handler) )
161173 . route ( "/check" , delete ( cancel_handler) )
162174 . route ( "/stream" , get ( stream_handler) )
163175 . with_state ( ( pool, email_client) )
176+ . layer ( cors)
164177}
0 commit comments