Add CORS allow list

This commit is contained in:
Brandon Thomas committed 2020-05-26 22:21:09 -04:00
1 parent 450c4ebe0a
commit d4b1fa93b1
1 file changed
+12 -1
+12 -1
View File
@@ -99,9 +99,20 @@ async fn main() -> std::io::Result<()> {
HttpServer::new(move || App::new()
.wrap(Logger::default())
.wrap(
Cors::new()
.allowed_origin("http://localhost:12345")
.allowed_origin("http://localhost:8080")
.allowed_origin("http://trumped.com")
.allowed_origin("http://jungle.horse")
.allowed_methods(vec!["GET", "POST"])
//.allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
//.allowed_header(http::header::CONTENT_TYPE)
.max_age(3600)
.finish())
.service(Files::new("/frontend", asset_directory.clone()).show_files_listing())
.service(
web::resource("/tts")
web::resource("/advanced_tts")
.route(web::post().to(post_tts))
.route(web::head().to(|| HttpResponse::Ok()))
)