summaryrefslogtreecommitdiff
path: root/server/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/main.rs')
-rw-r--r--server/src/main.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/server/src/main.rs b/server/src/main.rs
index 7a6b1b7..9a4f781 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -8,6 +8,7 @@ use rocket::http::Status;
use rocket::response::status::{Custom, NotFound};
use rocket::serde::json::Json;
use rocket::{futures, Build, Rocket, State};
+use rocket_cors::AllowedOrigins;
use rocket_db_pools::{sqlx, Connection, Database};
use sqlx::Acquire;
use std::path::PathBuf;
@@ -1465,6 +1466,15 @@ async fn run_migrations(rocket: Rocket<Build>) -> fairing::Result {
fn rocket_from_config(figment: Figment) -> Rocket<Build> {
let basepath = "/api/v1";
+
+ let cors = rocket_cors::CorsOptions {
+ allowed_origins: AllowedOrigins::all(),
+ allow_credentials: false,
+ ..Default::default()
+ }
+ .to_cors()
+ .unwrap();
+
rocket::custom(figment)
.attach(Db::init())
.attach(AdHoc::try_on_ignite("Database Migrations", run_migrations))
@@ -1497,6 +1507,7 @@ fn rocket_from_config(figment: Figment) -> Rocket<Build> {
translation_reviews,
],
)
+ .attach(cors)
.attach(auth::stage(basepath))
.attach(git_root::stage())
.attach(authorized_keys::stage())