You've already forked AstralRinth
forked from xxxOFFxxx/AstralRinth
Make CORS work (#52)
* Make CORS work * Add use statement * Add to TOML
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -1,5 +1,6 @@
|
||||
use actix_web::middleware::Logger;
|
||||
use actix_web::{web, App, HttpServer};
|
||||
use actix_cors::Cors;
|
||||
use actix_web::{web, App, HttpServer, http};
|
||||
use env_logger::Env;
|
||||
use gumdrop::Options;
|
||||
use log::{info, warn};
|
||||
@@ -170,6 +171,15 @@ async fn main() -> std::io::Result<()> {
|
||||
// Init App
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.wrap(
|
||||
Cors::new()
|
||||
.allowed_origin("http://localhost:3000")
|
||||
.allowed_methods(vec!["GET", "POST"])
|
||||
.allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
|
||||
.allowed_header(http::header::CONTENT_TYPE)
|
||||
.max_age(3600)
|
||||
.finish()
|
||||
)
|
||||
.wrap(Logger::default())
|
||||
.wrap(Logger::new("%a %{User-Agent}i"))
|
||||
.data(pool.clone())
|
||||
|
||||
Reference in New Issue
Block a user